cgccliterals

Digit separator for literals in C


I have been able to use the digit-separator ' in my C projects thus far. They have all been compiled with the MSVC compiler with no problems.

I have just changed to using the GCC compiler instead, which does not allow these digit-separators and throws an error, when I use them. I assume the reason is because, Visual Studio uses the same compiler for C and C++, and in C++14 (I believe), ' digit separators are allowed.

If this is the case, is there then a digit separator usable in GCC? Those separators really help out a lot, when working with 64 bit register values in binary...


Solution

  • You should use -std=c++1y gcc/g++ option (and have the file named like a C++ file, e.g. cpp/cxx extension) to use ' in number literals.