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

Gurucharan Shetty shettyg at nicira.com
Tue Dec 10 23:10:21 UTC 2013


On Tue, Dec 10, 2013 at 5:49 AM, Helmut Schaa
<helmut.schaa at googlemail.com> wrote:
> 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?

There is work going on to port OVS to windows and MSVC is the compiler
for that work.
I did try out the solution given in the stackoverflow link given. It
does compile and the initialize() function gets called before main().

>
> 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
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list