GNOME Bugzilla – Bug 794635
gmacros: Don't define bogus __has_* macros
Last modified: 2018-03-26 11:44:50 UTC
This pollutes the reserved compiler namespace and breaks applications trying to do their own feature detection. For instance, this falsely detects that alloca is not a builtin on gcc: #include <glib.h> #if defined(__has_builtin) # if !__has_builtin(alloca) # error "wtf glib?" # endif #else /* version-checking to determine alloca type */ #endif Instead, define our own g_macro__has_* versions that have the behaviour that we need.
Created attachment 370061 [details] [review] gmacros: Don't define bogus __has_* macros This pollutes the reserved compiler namespace and breaks applications trying to do their own feature detection. For instance, this falsely detects that alloca is not a builtin on gcc: #include <glib.h> #if defined(__has_builtin) # if !__has_builtin(alloca) # error "wtf glib?" # endif #else /* version-checking to determine alloca existence */ #endif Instead, define our own g_macro__has_* versions that have the behaviour that we need.
Created attachment 370062 [details] [review] gmacros: Don't define bogus __has_* macros This pollutes the reserved compiler namespace and breaks applications trying to do their own feature detection. For instance, this falsely detects that alloca is not a builtin on gcc: #include <glib.h> #if defined(__has_builtin) # if !__has_builtin(alloca) # error "wtf glib?" # endif #else /* version-checking to determine alloca existence */ #endif Instead, define our own g_macro__has_* versions that have the behaviour that we need.
Sorry about the bogus repetition, git-bz has some weird corner-cases. Do tell me if I should file this as a PR on gitlab instead, wasn't sure what the status was!
Review of attachment 370062 [details] [review]: ::: glib/gmacros.h @@ +119,3 @@ + */ + +#define g_macro_eval_false(x) 0 Why add g_macro_eval_false()? Why not just define the other macros to 0 directly?
Created attachment 370145 [details] [review] gmacros: Don't define bogus __has_* macros I thought it would avoid any pre-processor corner-cases to define it like that, but I can't actually find any, so here's an updated patch.
Review of attachment 370145 [details] [review]: OK, please push to master.
Thanks! Attachment 370145 [details] pushed as e2bd6a6 - gmacros: Don't define bogus __has_* macros