]> www.ginac.de Git - cln.git/blob - include/cln/modules.h
[bugfix] Public headers need GMP_DEMANDS_UINTD_* macros.
[cln.git] / include / cln / modules.h
1 // Macros for correct module ordering.
2
3 #ifndef _CL_MODULES_H
4 #define _CL_MODULES_H
5
6 // global constructor/destructor naming.
7 #include "cln/config.h"
8
9 // Concatenation of macroexpanded tokens.
10 // Equivalent to CL_CONCAT in src/base/cl_macros.h which we do not want
11 // to expose, however.
12 #define CL_CONCATENATE_(xxx,yyy)  xxx##yyy
13 #define CL_CONCATENATE(xxx,yyy)  CL_CONCATENATE_(xxx,yyy)
14
15 // Sometimes a link time dependency is needed, but without requirements
16 // on initialization order.
17 //
18 // CL_FORCE_LINK(dummy,external_variable)
19 // forces a link time reference to the external_variable.
20 #include <cstdlib>
21 #if 0
22 // This definition does not work.  It gets optimized away by g++ 3.1.
23 #define CL_FORCE_LINK(dummy,external_variable) \
24   static const void* const dummy[] = { &dummy, &external_variable };
25 #else
26 #define CL_FORCE_LINK(dummy,external_variable) \
27   static const                                                          \
28   struct dummy {                                                        \
29     inline dummy () {                                                   \
30       if ((void*) &external_variable == (void*) this)                   \
31         abort();                                                        \
32     }                                                                   \
33   }                                                                     \
34   CL_CONCATENATE(dummy,_instance);
35 #endif
36
37 #endif /* _CL_MODULES_H */