[vbox-dev] reserved identifier violation

Markus Elfring Markus.Elfring at web.de
Mon Feb 16 05:38:44 PST 2009


Thanks for your detailed explanation.


Jens Schweikhardt wrote:
> Any library (or API) provider faces a dilemma because he must invade one 
> of the two namespaces. VirtualBox chose to not invade the application 
> name space where practical. This means use of underscores as prefix in 
> places where the application writer is not supposed to use such identifiers.

I find this a questionable design decision.


> While this is technically causing undefined behavior, it is 
> a conscious decision because we support compilation of VirtualBox only 
> on a very limited number of implementations, the implementation 
> namespace of which is known to us.

Would you like to avoid more situations to build on undefined behavior?


> The __BEGIN_DECLS macro is a good example for this.

I imagine that this symbol might be too short to avoid all potential conflicts.


> As for header include guards, using __FOO_H is a common way to not 
> invade the app name space (see libvirt or the python binding for XPCOM 
> and many more).

I have got the impression that this is just a bad habit if the reserved naming pattern is used in source code which does not belong to the implementation of a (C/C++) compiler.
http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html

I suggest to use longer names to make important identfiers unique.
http://en.wikipedia.org/wiki/Include_guard#Difficulties


> If you happen to find a real problem due to identifier name clash (in an 
> implementation we support) we'd be of course happy to hear about it.

I try to increase attention for such an implementation detail before software developers and users are affected in unexpected ways by wrong applications of naming conventions.

Regards,
Markus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1753 bytes
Desc: S/MIME Cryptographic Signature
Url : http://www.virtualbox.org/pipermail/vbox-dev/attachments/20090216/ec420de4/attachment-0001.bin 


More information about the vbox-dev mailing list