delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/04/18/13:09:21

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> <1cbe225f0704160341o5587b102m665ede86190ba174 AT mail DOT gmail DOT com>
Subject: RE: C++ name with leading underscore character not Compiling
Date: Mon, 16 Apr 2007 11:52:23 +0100
Message-ID: <019301c78015$506519a0$2e08a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <1cbe225f0704160341o5587b102m665ede86190ba174@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 11:42, Chelton Evans wrote:

> Thanks for the language correction. However the compiler is braking.
> Here is some of the code and the error messages reported in compilation.
> 
> I have tested this on two different computers and the same error messages
>  were reported.  When I changed the _N to N or something else the
> compilation continued
>  on to the next error. Hence it is an underscore problem.

  No, hence "_N" is a macro that has been defined by an earlier header to mean
something else.  Take a look at the pre-processed source to see what your code
actually looks like to the compiler.  What you have done is effectively
something like

#define _N  Hello world, this is a macro
class gobjMyCircle : public gobj
{
public:


  gobjMyCircle
  (
    doublec theta0,
    doublec theta1,
    doublec xaxislength,
    doublec yaxislength,
    uintc _N=360
  );
}


> Thanks for your response, I will think twice before using an
> underscore, even though
>  I do no agree with it being reserved. It is very important to have
> programs that
>  compile across other platforms.

  That is /why/ it is reserved.  The compiler, toolchain, C library and OS
need to define symbols and labels in order to communicate with each other.  In
order to prevent there from being many many clashes with variable names and
definitions in the user's code, a simple way to divide up the namespace has
been chosen and mandated by the standard: everything that begins with an
underscore belongs to the system level and is none of the user's business to
interfere with, anything that does not begin with an underscore belongs to the
user and is none of the system's business to interfere with.


    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