ROSE  0.9.9.139
rosedll.h
1 #ifndef __ROSEDLL__
2 #define __ROSEDLL__
3 
4 /******************************************************************
5  * tps (02/24/2010)
6  * A DLL file has a layout very similar to an .exe file, with one important difference —
7  * a DLL file contains an exports table. The exports table contains the name of every function
8  * that the DLL exports to other executables. These functions are the entry points into the DLL;
9  * only the functions in the exports table can be accessed by other executables. Any other functions
10  * in the DLL are private to the DLL.
11  *
12  * To export a function from a DLL use the keyword : __declspec(dllexport) in the functions definition
13  *
14  * A program that uses public symbols defined by a DLL is said to import them. When you create header files
15  * for applications that use your DLLs to build with, use __declspec(dllimport) on the declarations
16  * of the public symbols. The keyword __declspec(dllimport) works with the __declspec(dllexport) keyword.
17  *
18  * You can use the same header file for both the DLL and the client application.
19  * To do this, use a special preprocessor symbol that indicates whether you are building the DLL or
20  * building the client application. To defined if you export a symbol use the library name and then _EXPORTS,
21  * for ROSE this would be ROSE_DLL_EXPORTS. I.e. when you compile the ROSE DLL, ROSE_DLL_EXPORTS is defined
22  * and when you compile the user code that uses the ROSE DLL, ROSE_DLL_IMPORTS is defined.
23  *
24  * In the configuration below ROSE_DLL_API is defined empty space as default. Special cases are:
25  * 1) Windows: then __declspec(dllimport/export) are used
26  * 2) Linux - GNUC >=4 and ROSE not compiling ROSE: then the visibility attribute is used to set
27  * all symbols hidden - to simulate the effect that occurs under Windows in Linux
28  ******************************************************************/
29 
30 #if defined _WIN32 || defined __CYGWIN__
31  #define ROSE_DLL_HELPER_DLL_IMPORT __declspec(dllimport)
32  #define ROSE_DLL_HELPER_DLL_EXPORT __declspec(dllexport)
33  #define ROSE_DLL_HELPER_DLL_LOCAL
34 #else
35 #if __GNUC__ >= 4 && !defined(USE_ROSE)
36  #define ROSE_DLL_HELPER_DLL_IMPORT __attribute__ ((visibility("default")))
37  #define ROSE_DLL_HELPER_DLL_EXPORT __attribute__ ((visibility("default")))
38  #define ROSE_DLL_HELPER_DLL_LOCAL __attribute__ ((visibility("hidden")))
39  #else
40  #define ROSE_DLL_HELPER_DLL_IMPORT
41  #define ROSE_DLL_HELPER_DLL_EXPORT
42  #define ROSE_DLL_HELPER_DLL_LOCAL
43  #endif
44 #endif
45 
46 // ROSE_DLL_EXPORTS is only defined for cmake
47  #ifdef ROSE_DLL_EXPORTS // defined if we are building the ROSE DLL (instead of using it)
48  #define ROSE_DLL_API ROSE_DLL_HELPER_DLL_EXPORT
49  #else
50  #define ROSE_DLL_API ROSE_DLL_HELPER_DLL_IMPORT
51  #endif // ROSE_DLL_DLL_EXPORTS
52  #define ROSE_DLL_LOCAL ROSE_DLL_HELPER_DLL_LOCAL
53  #ifdef ROSE_UTIL_EXPORTS
54  #define ROSE_UTIL_API ROSE_DLL_HELPER_DLL_EXPORT
55  #else
56  #define ROSE_UTIL_API ROSE_DLL_HELPER_DLL_IMPORT
57  #endif
58 
59 
60 // DQ (10/19/2010): Need to test if we can remove this.
61 // We should not reference CXX_IS_ROSE_ANALYSIS except in source code.
62 // tps : this is probably not needed anymore
63 // undef ROSE_ROSETTA_API if rose analyses itself.
64 // #if CXX_IS_ROSE_ANALYSIS
65 // #undef ROSE_DLL_API
66 // #define ROSE_DLL_API
67 //#endif
68 
69 #ifdef USE_ROSE
70 // #error "ROSE_DLL_API = "ROSE_DLL_API
71 // #define ROSE_DLL_API
72 #endif
73 
74 #endif
75