GNOME Bugzilla – Bug 79633
Leading underscores in identifiers considered harmful
Last modified: 2013-10-22 09:51:20 UTC
Hi. I noticed in the GTK 2.0 release notes the following text: * The GTK+ libraries use an '_' prefix to indicate private symbols that must not be used by applications. Of course, using a leading '_' for internal symbols is hardly unique to gtk+; it's all over the GNOME source base. But bugzilla doesn't let me report a bug against the entire GNOME project, so I will start here. Identifiers with a leading '_' are reserved by the ANSI C standard for the C environment for external linkage, or for any use if the '_' is followed by an uppercase letter or another underscore. No application or library (except for the system C library) is allowed to use such symbols, at the risk of conflicts. A prefix like "gtk__" would be more sensical.
We know, we don't care ;-P - any other prefix would either be hideously long or hideously ugly, would not make it clear that the namespace gtk__foo ... this doesn't look sufficiently private gtk_private_ too long gtkP_foo .... ugh Plus, it's really best not to stick things into the middle, since it involves a non-obvious transformation, so you really want a prefix to add to the gtk_foo name. - We aren't randomly trodding all over the _* namespace but only in _ + namespace prefix - GTK+ has for a long time used structure names like _GtkWidget without any reported problems. And since these symbols are defined as library private, if there is ever a problem we can worry about it then.
*** Bug 596031 has been marked as a duplicate of this bug. ***
(In reply to comment #1) > And since these symbols are defined as library private, if > there is ever a problem we can worry about it then. I suggest to reconsider your application of name patterns. https://www.securecoding.cert.org/confluence/display/seccode/DCL37-C.+Do+not+use+identifiers+that+are+reserved+for+the+implementation
We will, as soon as you show a concrete case where the convention causes harm.
(In reply to comment #4) Would you like to adjust any identifiers so that they adhere to the rules of the C programming language? Do you care to avoid any unexpected and unwanted damages by correct software design?
comment #1 contains all that needs to be said about this.