I have some code like this that I need to make cross-platform:
int __attribute__((noinline)) fn() { return 0; }
I want to use Waf to write a config.h that contains
#define ATTRIBUTE(attr) __attribute__((attr))
if the compiler supports this extension, and
#define ATTRIBUTE(attr)
otherwise, so I can rewrite the function like this:
int ATTRIBUTE(noinline) fn() { return 0; }
Looking at the configuration documentation I don't see an obvious way to do this. The best I could do is define some HAS_ATTRIBUTES
macro if a code snippet using this feature fails to compile.
Does waf support configuring the project in this manner, or will I have to write a second config header manually?
(I am specifically looking for a waf answer. If I could use something else, I would.)
Here is how I solved it.
In my wscript:
And then in a manually-created config header:
I would have hoped to avoid manually creating the header like this, but it does the job.