I came across some variable name like __gc_context.
I started thinking a bit if I should tell the author of that code that names
starting with underscores are reserved for the implementation. I decided not
to because it would make me look like somebody who just wastes other
people's time instead of finding real bugs.
Come on, how serious should we take this rule? This wont ever be an issue 19 3327
ok wrote: I came across some variable name like __gc_context. I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation. I decided not to because it would make me look like somebody who just wastes other people's time instead of finding real bugs. Come on, how serious should we take this rule?
Very serious(ly)!
This wont ever be an issue
It is, and a big one at that. C&V 7.1.3p1:
Each header declares or defines all identifiers listed in its associated
subclause, and optionally declares or defines identifiers listed in its
associated future library directions subclause and identifiers which are
always reserved either for any use or for use as file scope identifiers.
— 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.
PS
Are you sure you're not trolling?
--
BR, Vladimir
You definitely intend to start living sometime soon.
> I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation.
I think that the convention about names says that names starting with
underscores and with the first non-underscore letter capitalized are
reserved for the implementation of the C library. I saw a suggestion
made by P.J. Plauger on his book "STD C Library".
Particularly I avoid naming variables with underscores as first
characters because I had problems in the past with Tru64 C library
implementation. However I'm not sure if you should worry about it. A
lot of people use underscores to start names they consider "internal"
and are not intended to be exported.
ok wrote On 03/01/06 13:13,: I came across some variable name like __gc_context. I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation. I decided not to because it would make me look like somebody who just wastes other people's time instead of finding real bugs. Come on, how serious should we take this rule? This wont ever be an issue
You are *so* right! Down with the pedants! Just for
the sake of interest, though, would you try the following
program on your system and tell us what the output is?
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <iso646.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
int __EXTENSIONS__ = __LINE__;
int __MATHERR_ERRNO _DONTCARE = __LINE__;
int __P = __LINE__;
int __PRAGMA_REDEFI NE_EXTNAME = __LINE__;
int ___errno = __LINE__;
int __assert = __LINE__;
int __buf = __LINE__;
int __filbuf = __LINE__;
int __flsbuf = __LINE__;
int __flt_rounds = __LINE__;
int __fltrounds = __LINE__;
int __i386 = __LINE__;
int __ia64 = __LINE__;
int __lint = __LINE__;
int __longlong_t = __LINE__;
int __posix_asctime _r = __LINE__;
int __posix_ctime_r = __LINE__;
int __posix_sigwait = __LINE__;
int __setp = __LINE__;
int __sigev_pad2 = __LINE__;
int __signo = __LINE__;
int __sparc = __LINE__;
int __strptime_dont zero = __LINE__;
int __time = __LINE__;
int __tm = __LINE__;
int __va_list = __LINE__;
#define SHOW(x) printf("%s == %d\n", STRING(x), x);
int main(void)
{
SHOW(__EXTENSIO NS__);
SHOW(__MATHERR_ ERRNO_DONTCARE) ;
SHOW(__P);
SHOW(__PRAGMA_R EDEFINE_EXTNAME );
SHOW(___errno);
SHOW(__assert);
SHOW(__buf);
SHOW(__filbuf);
SHOW(__flsbuf);
SHOW(__flt_roun ds);
SHOW(__fltround s);
SHOW(__i386);
SHOW(__ia64);
SHOW(__lint);
SHOW(__longlong _t);
SHOW(__posix_as ctime_r);
SHOW(__posix_ct ime_r);
SHOW(__posix_si gwait);
SHOW(__setp);
SHOW(__sigev_pa d2);
SHOW(__signo);
SHOW(__sparc);
SHOW(__strptime _dontzero);
SHOW(__time);
SHOW(__tm);
SHOW(__va_list) ;
return 0;
}
-- Er*********@sun .com
In article <du**********@n ews1brm.Central .Sun.COM>,
Eric Sosman <Er*********@su n.com> wrote: You are *so* right! Down with the pedants! Just for the sake of interest, though, would you try the following program on your system and tell us what the output is?
#define SHOW(x) printf("%s == %d\n", STRING(x), x);
You don't define STRING(x)
--
Prototypes are supertypes of their clones. -- maplesoft
ok wrote: I came across some variable name like __gc_context. I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation. I decided not to because it would make me look like somebody who just wastes other people's time instead of finding real bugs. Come on, how serious should we take this rule? This wont ever be an issue
After spending/wasting a day debugging a largish tool that managed to
define
_sys_read, which on one OS clashed with an actual system function which
even the dynamic loader ended up in - failing to load the app, debugger
provided nothing meaningfull etc etc:
Just don't ever do it.
Especially when you know you shouldn't do it.
"Eric Sosman" <Er*********@su n.com> wrote in message
news:du******** **@news1brm.Cen tral.Sun.COM...
ok wrote On 03/01/06 13:13,: I came across some variable name like __gc_context. I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation. I decided not to because it would make me look like somebody who just wastes other people's time instead of finding real bugs. Come on, how serious should we take this rule? This wont ever be an issue
You are *so* right! Down with the pedants! Just for the sake of interest, though, would you try the following program on your system and tell us what the output is?
-snip code
Won't compile. I get the following "fatal error C1083: Cannot open include
file: 'inttypes.h': No such file or directory."
Is inttypes.h a standard header?
--
MrG{DRGN}
On Wed, 01 Mar 2006 19:42:12 GMT, "MrG{DRGN}" <Ia****@here.co m> wrote: "Eric Sosman" <Er*********@su n.com> wrote in message news:du******* ***@news1brm.Ce ntral.Sun.COM.. .
ok wrote On 03/01/06 13:13,: I came across some variable name like __gc_context. I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation. I decided not to because it would make me look like somebody who just wastes other people's time instead of finding real bugs. Come on, how serious should we take this rule? This wont ever be an issue
You are *so* right! Down with the pedants! Just for the sake of interest, though, would you try the following program on your system and tell us what the output is?
-snip code
Won't compile. I get the following "fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory." Is inttypes.h a standard header?
Yes, in C99.
--
Al Balmer
Sun City, AZ
ok said: I came across some variable name like __gc_context. I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation. I decided not to because it would make me look like somebody who just wastes other people's time instead of finding real bugs.
Please stop wasting other people's time, and go fix the real bug you just
found.
Come on, how serious should we take this rule? This wont ever be an issue
....except when it becomes an issue.
If you stay the hell out of implementation namespace, you eliminate one
possible cause of bugs. Isn't that a good thing?
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Richard Heathfield <in*****@invali d.invalid> writes: ok said: I came across some variable name like __gc_context. I started thinking a bit if I should tell the author of that code that names starting with underscores are reserved for the implementation. I decided not to because it would make me look like somebody who just wastes other people's time instead of finding real bugs.
Please stop wasting other people's time, and go fix the real bug you just found.
He said it's in somebody else's code; he may not be in a position to
fix it.
If the code in question is part of the implementation, there's no
problem. If it isn't, using an identifier starting with "__" is
unsafe -- but in practice, it's *probably* only going to be a problem
if the code is used with an implementation that happens to use that
specific identifier.
To the OP: sure, go ahead and notify the author; that would have been
just as easy as notifying the rest of us.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tom Blackwell |
last post by:
Today I installed the 'mechanoid' package from sourceforge, but the
self-test failed. On looking into it, I noticed odd behaviour in the
handling of single underscore module names. Importing into the
current namespace with 'from' seems to work, but accessing members of
the imported module only works if the imported name is qualified by
the containing module name.
For example:
>>> from mechanoid import _mechanoid_Common
>>> from...
|
by: Walter Tross |
last post by:
Somebody with a very regulatory mind in this newsgroup has written
that it's better not to use a leading underscore for class member
names, because names with a leading underscore are used internally by
compilers (well, not so internally, since they appear in header
files).
I personally use the leading underscore (followed by a lower case
letter), which I consider to be much more readable than the trailing
underscore.
My reasoning is...
|
by: Axter |
last post by:
Section 17.4.3.1.2 states that each name that begins with an underscore
is reserved to the implementation for use as a name in the global
namespace.
Exactly what defines the implementation?
Is it only narrowly defined by the compiler's internal name handling?
Or does it also include the library that comes with the compiler?
Does it include the OS library as part of the implementation?
|
by: AntiPasta |
last post by:
A good day to you all,
I had an old code project lying around, written in C + assembly and
targeted for X86 Linux, that I intended to compile on Win32 as well.
I'm using GCC and NASM on Linux (not really sure which version but
nothing too esoteric), and MingW and NASM on Windows. I quickly ran
into the problem of differing calling conventions between Linux and
Windows: my assembly code exports several symbols, but the MingW GCC
won't...
|
by: Jim Langston |
last post by:
I know that functions starting with an underscore, or two underscores, are
reserved by the compiler/c++ and should not be used by the user and may
cause undefined behavior. My question is, how likely is it to actually
cause undefined behavior?
The reason I'm asking is I'm using a game engine where the sockets code is
not working correctly on my computer, but seems to work correctly on
everyone elses. I am not compiling the dll myself,...
| |
by: Bit Byte |
last post by:
I have the following struct:
typedef struct
{
string symbol;
string synonym;
Synonym(string _synonym, string _symbol) {
synonym = _synonym;
symbol = _symbol;
}
|
by: PromisedOyster |
last post by:
Many in our development team have came from a C++ background and are in
the practice of prefixing private class variables with an underscore to
improve readability and avoid naming collisions with local variables
and parameters. This has become our standard.
ie private string _name;
as opposed to:
ie private string name;
|
by: laredotornado |
last post by:
Hi,
I'm using PHP 4.4.4. I notice for form elements that contain spaces,
PHP substitutes an underscore for the element name when the form is
submitted. For example, if I have this page (test.php)
<html>
<body onload="document.forms.submit();">
<form name="f" action="test_response.php" method="post">
|
by: Pete C |
last post by:
I was looking at Section 17.4.3.1 and I can't work out whether macro
names are also covered by Section 17.4.3.1.2 ("Global names").
I often see preple chastised for using include guards like
_INCLUDED_BLAH_H (and I avoid them myself "just to be on the safe
side"). But if this is a mistake, then it is an astonishingly common
one. There are dozens of well-known libraries in my /usr/include that
do it.
Is this technically a mistake that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |