[ovs-dev] [RFC 1/4] compiler: Add OVS_CONSTRUCTOR to mark functions as init functions

Helmut Schaa helmut.schaa at googlemail.com
Tue Dec 10 13:49:27 UTC 2013


Functions marked with OVS_CONSTRUCTOR are called unconditionally
before main.

Signed-off-by: Helmut Schaa <helmut.schaa at googlemail.com>
---

This works with gcc (tested), should work with clang (untested)
but does not work with MSVS.

Could anyone using MSVC try if the solution described at
http://stackoverflow.com/questions/1113409/attribute-constructor-equivalent-in-vc
is suitable?

Is MSVC even supported in OVS?

Thanks,
Helmut

 lib/compiler.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/compiler.h b/lib/compiler.h
index 0dbacbf..5052ee7 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -179,4 +179,8 @@
 #define OVS_PACKED(DECL) __pragma(pack(push, 1)) DECL __pragma(pack(pop))
 #endif
 
+#ifdef __GNUC__
+#define OVS_CONSTRUCTOR(DECL) __attribute__((constructor)) DECL
+#endif
+
 #endif /* compiler.h */
-- 
1.8.1.4




More information about the dev mailing list