delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/04/16/05:41:56

X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
References: <1cbe225f0704160234u24b104a5o9b459178e895a5a8 AT mail DOT gmail DOT com>
Subject: RE: C++ name with leading underscore character not Compiling
Date: Mon, 16 Apr 2007 10:41:08 +0100
Message-ID: <018901c7800b$5c4ec450$2e08a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <1cbe225f0704160234u24b104a5o9b459178e895a5a8@mail.gmail.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 16 April 2007 10:34, Chelton Evans wrote:

> I believe it is legal to have a C++ variable name with a leading
>  underscore.

  No.  All names beginning with an underscore are reserved for the
implementation.

  However, the compiler allows it, because for all it knows your code could be
part of the OS or libc that has the legitimate right to use such identifiers.
But technically it's actually undefined behaviour, the reason being that you
may tread on a reserved name.

> A name with two underscores is reserved, so
>  I guess this is illegal. Currently the two cases are reversed.
>  class hat { ... void fred( int __name) ... compiles, but
>  class hat { ... void fred( int _name)... which is legal does not
>  compile.
> 
> Could you confirm or deny the problem.

  I deny it:

/artimi $ cat t.cpp

class hat {

        void fred( int _name);
        void fred2( int __name);
};

/artimi $ g++ -c t.cpp -o t.o -W -Wall
/artimi $

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019