In other words, may static (=file-scoped) globals begin with exactly one underscore without creating the possibility of nameclashes with the C implementation?
https://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html says that "... reserved names include all external identifiers (global functions and variables) that begin with an underscore (‘_’) ..." (emphasis mine).
I've noticed the Linux kernel starts functions that probably shouldn't be called directly with double underscores.
I find this concept useful, and I find _(_)something
slightly easier to read than something_
when it comes to distinguishing "private" identifiers, but I understand (?) double underscore invite name clashes with the C implementation.
Are global, static _variables
and _functions
safe?
Standards reserves prefixes with an underscore1.
1 (Quoted from: ISO/IEC 9899:201x 7.1.3 Reserved identifiers 1)
All identifiers that begin with an underscore and either an uppercase letter or another
underscore are always reserved for any use.
All identifiers that begin with an underscore are always reserved for use as identifiers
with file scope in both the ordinary and tag name spaces.
It is not safe. Depending on architecture your code may require some relocations even for static
objects. As result their names must be visible to linker as well as names of CRT symbols. And this may cause clashes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With