▲ | tavianator 13 hours ago | |||||||
Nice! I used to do something similar, don't remember exactly why I had to switch but the two step process did become necessary at some point. Just from a quick peek at that repo, nowadays you can write #if __has_attribute(cold) and avoid the configure test entirely. Probably wasn't a thing 10 years ago though :) | ||||||||
▲ | o11c 12 hours ago | parent | next [-] | |||||||
The problem is that the various `__has_foo` aren't actually reliable in practice - they don't tell you if the attribute, builtin, include, etc. actually works the way it's supposed to without bugs, or if it includes a particular feature (accepts a new optional argument, or allows new values for an existing argument, etc.). | ||||||||
▲ | aaronmdjones 7 hours ago | parent | prev | next [-] | |||||||
You should use double underscores on attribute names to avoid conflicts with macros (user-defined macros beginning with double underscores are forbidden, as identifiers beginning with double underscores are reserved).
| ||||||||
▲ | codys 13 hours ago | parent | prev [-] | |||||||
yep. C's really come a long way with the special operators for checking if attributes exist, if builtins exist, if headers exist, etc. Covers a very large part of what is needed, making fewer and fewer things need to end up in configure scripts. I think most of what's left is checking for items (types, functions) existence and their shape, as you were doing :). I can dream about getting a nice special operator to check for fields/functions, would let us remove even more from configure time, but I suspect we won't because that requires type resolution and none of the existing special operators do that. | ||||||||
|