[ofa-general] PATCH[1/6] Windows port of libibmad - mad.h

Jason Gunthorpe jgunthorpe at obsidianresearch.com
Tue Dec 23 10:52:14 PST 2008


On Mon, Dec 22, 2008 at 10:44:35PM -0800, Sean Hefty wrote:

> >If we will add "extern" keyword for exported symbols and somewhere in
> >windows-specific header file it will be redefined as
> >
> >#define extern __declspec(dllexport)
> 
> I don't think we want to get into redefining keywords.

Right, that's evil..

Anyhow, on linux it is considered a best practice for library authors
to do the same as what the above option does on windows - explicitly
mark symbols as exported. This prevents symbol table pollution.

To do this you use the -fvisibility=hidden flag and mark exported
symbols with __attribute__((visibility("default"))). Everything else
will not be available for dynamic linking.

> >> +MAD_EXPORT uint32_t mad_get_field(void *buf, int base_offs, int field);
> >> +MAD_EXPORT void mad_set_field(void *buf, int base_offs, int field, uint32_t
> >val);
> >
> >Windows don't like "inline"?
> 
> The compiler doesn't allow it in the header file.

Not even static inline? Inline functions in header should all be
static inline or extern inline to avoid comdefs..

Jason



More information about the general mailing list