Last active
August 29, 2015 14:02
-
-
Save mlabbe/6df2f9f8cdfe5a3b6e7e to your computer and use it in GitHub Desktop.
Compiler extensions made portable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Compiler extensions made portable | |
Usage: | |
In MSVC, attributes must be on declarations in addition to prototypes. | |
Use _ATTRIBUTES to conditionally declare them, depending on compiler. | |
// Prototype | |
EXT_warn_unused_result EXT_force_inline int SomeFunc( void ); | |
// Decl | |
_ATTRIBUTES(EXT_warn_unused_result EXT_force_inline) int SomeFunc( void ); | |
\endcode | |
*/ | |
#if defined(__GNUC__) && (__gnuc__ >= 4) | |
#define EXT_warn_unused_result __attribute__((warn_unused_result)) | |
#define EXT_force_inline __attribute__((always_inline)) | |
#define EXT_pure_function __attribute__((pure)) | |
#define EXT_const_function __attribute__((const)) | |
#define EXT_no_vtable | |
#define _ATTRIBUTES(x) | |
#elif defined(_MSC_VER) && (_MSC_VER >= 1700) | |
#define EXT_warn_unused_result _Check_return_ | |
#define EXT_force_inline __forceinline | |
#define EXT_pure_function | |
#define EXT_const_function | |
#define EXT_no_vtable __declspec(novtable) | |
#define _ATTRIBUTES(x) x | |
#else | |
#define EXT_warn_unused_result | |
#define EXT_force_inline inline | |
#define EXT_pure_function | |
#define EXT_const_function | |
#define _ATTRIBUTES(x) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment