My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
main.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef _SAL_MAIN_H_
21 #define _SAL_MAIN_H_
22 
23 #include "sal/config.h"
24 
25 #include "sal/saldllapi.h"
26 #include "sal/types.h"
27 
28 #if defined AIX
29 #include <unistd.h>
30 #endif
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
38 
39 #if defined IOS || defined ANDROID
40 
41 #error No code that includes this should be built for iOS or Android
42 
43 #else
44 
45 #define SAL_MAIN_WITH_ARGS_IMPL \
46 int SAL_CALL main(int argc, char ** argv) \
47 { \
48  int ret; \
49  sal_detail_initialize(argc, argv); \
50  ret = sal_main_with_args(argc, argv); \
51  sal_detail_deinitialize(); \
52  return ret; \
53 }
54 
55 #define SAL_MAIN_IMPL \
56 int SAL_CALL main(int argc, char ** argv) \
57 { \
58  int ret; \
59  sal_detail_initialize(argc, argv); \
60  ret = sal_main(); \
61  sal_detail_deinitialize(); \
62  return ret; \
63 }
64 
65 #endif
66 
67 
68 /* Definition macros for CRT entries */
69 
70 #ifdef SAL_W32
71 
72 #ifndef INCLUDED_STDLIB_H
73 #include <stdlib.h>
74 #define INCLUDED_STDLIB_H
75 #endif
76 
77 /* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
78 
79 #ifndef WINAPI
80 # define WINAPI __stdcall
81 #endif
82 
83 #if !defined(DECLARE_HANDLE)
84 # ifdef STRICT
85  typedef void *HANDLE;
86 # define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
87 # else
88  typedef void *PVOID;
89  typedef PVOID HANDLE;
90 # define DECLARE_HANDLE(name) typedef HANDLE name
91 # endif
92 DECLARE_HANDLE(HINSTANCE);
93 #endif
94 
95 
96 
97 #define SAL_WIN_WinMain \
98 int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
99 { \
100  int argc = __argc; char ** argv = __argv; \
101  (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \
102  return main(argc, argv); \
103 }
104 
105 #else /* ! SAL_W32 */
106 
107 # define SAL_WIN_WinMain
108 
109 #endif /* ! SAL_W32 */
110 
111 /* Implementation macro */
112 
113 #define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
114  static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
115  SAL_MAIN_WITH_ARGS_IMPL \
116  SAL_WIN_WinMain \
117  static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
118 
119 #define SAL_IMPLEMENT_MAIN() \
120  static int SAL_CALL sal_main(void); \
121  SAL_MAIN_IMPL \
122  SAL_WIN_WinMain \
123  static int SAL_CALL sal_main(void)
124 
125 /*
126  "How to use" Examples:
127 
128  #include <sal/main.h>
129 
130  SAL_IMPLEMENT_MAIN()
131  {
132  DoSomething();
133 
134  return 0;
135  }
136 
137  SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
138  {
139  DoSomethingWithArgs(argc, argv);
140 
141  return 0;
142  }
143 
144 */
145 
146 #ifdef __cplusplus
147 } /* extern "C" */
148 #endif
149 
150 #endif /* _SAL_MAIN_H_ */
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */