Search code examples
cvisual-c++gccattributesc99

Dealing with __attribute__ in MSVC


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!


Solution

  • Take a look at the GCC Manual and find out what each attribute does. Then find out what the MSVC equivalent is. Some can be safely ignored but some you will want the replace.

    If you want your code to be truly cross platform, create your own set of macros that can be implemented correctly for each platform.