Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ identifiers

Tags:

c++

identifier

C++ Primer says:

The identifier we define in our programs may not contain 2 consecutive underscores, nor can identifier begin with an underscore followed immediately by an uppercase letter. In addition, identifiers be fined outside of a function may not begin with an underscore

All is well, but

int _c = 55;                  // outside function starts with _

int main () {

    int _A = 12;              // _ followed by uppercase letter
    cout << _A << endl;

    int __b__ =33;            // 2 consecutive __
    cout << __b__ << endl;

    cout << _c << endl;

}

Code above compiles perfectly fine on mac, g++ 4.7.1, using the following flags

g++ -pedantic -Wall -Werror -std=c++11 -O3 -funroll-loops -fprefetch-loop-arrays

What am i missing please?

like image 337
James Leonard Avatar asked Sep 03 '25 05:09

James Leonard


1 Answers

Crossing the street without looking out for traffic both ways doesn't guarantee that you are run over by a bus, but it is still a bad idea.

One of those days it isn't going to work...

like image 177
Bo Persson Avatar answered Sep 04 '25 20:09

Bo Persson