I've gotten a piece of code which applies __attribute__((const))
to some functions. Now, I'd rather not remove it when it's usable, but on the other hand, I do want to be more portable, so - I want to say
#if some condition here
#define ATTRIBUTE(an_attribute) __attribute__((an_attribute))
#else
#define ATTRIBUTE(an_attribute)
#endif
void foo(int x) ATTRIBUTE(const)
What should the condition be?
Notes:
- I know that, with C++17, we have this as a proper C++ attribute; but I can't assume C++17 is used. In fact, let's assume it isn't to make things simple.
- Extra points if you can also answer the question for
__attribute__((pure))
.