X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave.korn@artimi.com>
To: <cygwin@cygwin.com>
References: <1cbe225f0704160234u24b104a5o9b459178e895a5a8@mail.gmail.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
Content-Type: text/plain; 	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <1cbe225f0704160234u24b104a5o9b459178e895a5a8@mail.gmail.com>
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.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/

