ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rosedll.h
Go to the documentation of this file.
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 
47 // ROSE_DLL_EXPORTS is only defined for cmake
48  #ifdef ROSE_DLL_EXPORTS // defined if we are building the ROSE DLL (instead of using it)
49  #define ROSE_DLL_API ROSE_DLL_HELPER_DLL_EXPORT
50  #else
51  #define ROSE_DLL_API ROSE_DLL_HELPER_DLL_IMPORT
52  #endif // ROSE_DLL_DLL_EXPORTS
53  #define ROSE_DLL_LOCAL ROSE_DLL_HELPER_DLL_LOCAL
54  #ifdef ROSE_UTIL_EXPORTS
55  #define ROSE_UTIL_API ROSE_DLL_HELPER_DLL_EXPORT
56  #else
57  #define ROSE_UTIL_API ROSE_DLL_HELPER_DLL_IMPORT
58  #endif
59 
60 
61 // DQ (10/19/2010): Need to test if we can remove this.
62 // We should not reference CXX_IS_ROSE_ANALYSIS except in source code.
63 // tps : this is probably not needed anymore
64 // undef ROSE_ROSETTA_API if rose analyses itself.
65 // #if CXX_IS_ROSE_ANALYSIS
66 // #undef ROSE_DLL_API
67 // #define ROSE_DLL_API
68 //#endif
69 
70 #ifdef USE_ROSE
71 // #error "ROSE_DLL_API = "ROSE_DLL_API
72 // #define ROSE_DLL_API
73 #endif
74 
75 #endif
76