I was wondering what the best way to deal with code containing GCC's __attribute__
extension when using MSVC. Is the following a safe way of dealing with this:
#define __attribute__(x) /* blank - should simply ignore thanks to C preprocessor */
Thanks!
__attribute__
is not a macro, it is a GCC specific extension that needs to be replaced with appropriate equivalent Visual C++ has. Its equivalent is usually __declspec
:
http://msdn.microsoft.com/en-US/library/dabb5z75(v=vs.110).aspx
For example:
#if defined(_MSC_VER)
#define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
#else
#if defined(__GNUC__)
#define DLL_PUBLIC __attribute__ ((dllexport))
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With