Files
epics-base/src/libCom/misc/shareLib.h
1997-04-23 17:15:55 +00:00

90 lines
2.4 KiB
C

/*
* Use compiler specific key words to set up shareable library
* external symbols and entry points
*
* Right now this is only necessary for WIN32 DLL,
* the approach should be general enough for future systems, however.
*
*
* USAGE:
*
* In header files, declare variables, classes and functions
* to be __exported__ like this:
*
* epicsShareAPI int a_func (int arg); reference function
* epicsShareExtern int a_var; reference variable
* epicsShareDecl int a_var= 4; create variable instance
* class epicsShareClass a_class; reference a class
*
* Usually the epicsShare... macros expand to
* "import this from a DLL" (on WIN32, on Unix it's a NOP)
*
* In the implementation file, however, you write:
*
* #include <other_stuff.h>
* #define epicsExportSharedSymbols
* #include <what_I_implement.h>
* ! no more "foreign" includes from here on !
*
* The point is: define epicsExportSharedSymbols exacly and only
* right before you include the prototypes for what you implement!
* This time the epicsShare... macros expand to
* "export this from the DLL that we are building" (again only on WIN32)
*
* 8-22-96 -kuk-
*/
#undef epicsShareExtern
#undef epicsShareDecl
#undef epicsShareClass
#undef epicsShareAPI
#undef READONLY
#if defined(WIN32)
# if defined(epicsExportSharedSymbols)
# define epicsShareExtern __declspec(dllexport) extern
# define epicsShareClass __declspec(dllexport)
# else
# define epicsShareExtern __declspec(dllimport) extern
# define epicsShareClass __declspec(dllimport)
# endif
/*
* Subroutine removes arguments
*/
# define epicsShareAPI __stdcall
# define epicsShareDecl __declspec(dllexport)
# define READONLY const
#elif defined(VAXC)
/*
* VAXC creates FORTRAN common blocks when
* we use "extern int fred"/"int fred=4". Therefore,
* the initialization is not loaded unless we
* call a function in that object module.
*
* DEC CXX does not have this problem.
* We suspect (but do not know) that DEC C
* also does not have this problem.
*/
# define epicsShareExtern globalref
# define epicsShareDecl globaldef
# define READONLY const
#else
/* no WIN32 -> no import/export specifiers */
# define epicsShareExtern extern
# define epicsShareAPI
# define epicsShareClass
# define epicsShareDecl
# if defined(__STDC__)
# define READONLY const
# else
# define READONLY
# endif
#endif