What is max length for an C/C++ identifier on common (build) systems?

mbx picture mbx · May 15, 2011 · Viewed 26.4k times · Source

I don't remember the standard saying something of the max length for identifiers so in theory they can be long. In real life, those names could be limited by at least the compiler and linker implementations.

While this should work on all systems

int a;

this snippet

#!/usr/bin/perl
print "int" . "b" x 2**16 . ";";

creates a declarationen that gives undefined reference to std::somethings with ld while compiling/linking (using gcc/mingw).

So what are the size limits for an identifier on different systems?

Answer

Anders Lindahl picture Anders Lindahl · May 15, 2011