Question

I am seeing some behavior I can't quite explain. Consider test.cpp:

#include <iostream>
long double operator"" _N(long double a) { return a; }

int main(int argc, char** argv) {
    long double t = 4.0_N;
}

Issuing

g++ -std=c++11 test.cpp

gives me

test.cpp:2:22: error: expected suffix identifier
long double operator"" _N(long double V) { return V; }
                    ^

Making any of the the following changes will NOT give the error:

// #include <iostream>  // Is there some conflict with something in iostream then?
long double operator"" _N(long double a) { return a; }    
...

#include <iostream>
long double operator"" _P(long double a) { return a; } 
// (or most other letters and/or words) 
...

however, the problem persists for at least _B and _C (I didn't test the entire alphabet)...

What am I missing here?

More info:

$ g++ --version 
g++ (GCC) 4.8.2

Running in CygWin on 64-bit Windows 7 SP1.

Was it helpful?

Solution

With the preprocessed output you posted (http://pastebin.com/USSiRcGQ) we can see the problem right away:

long double operator "" 04(long double V) { return V; }

So you have some header file which does (the equivalent of) this:

#define _N 04

It would be interesting to know which header that is--you can try grep -rw _N /usr/include and see if it pops up.

Now that you know this, if you're brave I guess you could #undef _N, but really you should change to a suffix like _n or maybe something more descriptive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top