Skip to content

Helper macros to make the attribute syntax in MinGW/GCC cleaner.

License

Notifications You must be signed in to change notification settings

iSLC/CleanGCCAttributes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

CleanGCCAttributes

Helper macros to make the attribute syntax in GCC cleaner.

Example 1

Declaring a vector type:

typedef float V4SF __attribute__ ((__vector_size__(16)));

Becomes:

typedef float V4SF GATTRIB(vector_size(16));

Example 2

Forcing a function to always be inline:

inline float __attribute__ ((__always_inline__)) add(float a, float b)
{
    return a + b;
}

Becomes:

inline float GATTRIB(always_inline) add(float a, float b)
{
    return a + b;
}

Example 3

To specify more than one attribute, append an S to the macro name so that GATTRIB becomes GATTRIBS.

For example:

inline void __attribute__ ((__always_inline__, __nonnull__(1), __nothrow__, __unused__)) set_memory(void * ptr, int value, size_t num)
{
    memset(ptr, value, num);
}

Becomes:

inline void GATTRIBS(always_inline, nonnull(1), nothrow, unused) set_memory(void * ptr, int value, size_t num)
{
    memset(ptr, value, num);
}

Notes:

  • If you need extra attributes other than the one's included then feel free to create macros for them.
    • To add a new attribute you create a macro prefixed with GATTRIB_.
      • For example: #define GATTRIB_someattr __theattr__
  • The GATTRIBS macro supports up to 8 parameters. You must modify it if you need more than 8 attributes. Should be fairly easy.
  • There's also a shorter alias called GATTR included for convenience.

About

Helper macros to make the attribute syntax in MinGW/GCC cleaner.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages