I have a C ++ project that I compile using both g++ on my machine (compiling to the "host") and using an ARM processor using a cross-compiler (in my case arm-cortex_a8-linux-gnueabi-g++ ). I am in the process of converting to the C ++ 0x / 11 standard, and an error occurs when compiling the initialization list, which I could reproduce in the following fragment:
int main(void) { char c[1] = {-108}; }
This program seems to be correct, since -108 is the legal value for char . Compiling with g++ does not result in an error on the following command line:
g++ example.cc -std=c++0x
However, when I compile using a cross-compiler, for example:
arm-cortex_a8-linux-gnueabi-g++ example.cc -std=c++0x
I get the following error:
example.cc: In function 'int main()': example.cc:2:22: error: narrowing conversion of '-0x0000000000000006c' from 'int' to 'char' inside { } [-fpermissive]
Since the value is legal, this seems like an error. Can you explain why I get this error and what to do to solve it?
Edit : note that using positive values ββ(e.g. 108 ) is legal and does not result in an error for both compilers.
c ++ linux c ++ 11 cross-compiling
Andy Thomas
source share