[Bug preprocessor/16903] New: __LINE__ is not implemented in preprocessor
whitis at freelabs dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 6 17:11:00 GMT 2004
__LINE__ appears to be implemented in the parser, with an effect similar to
const int __LINE__ = 57;
Instead of at preprocessor time, where it would behave similarly to:
#define __LINE__ 57
This means you cannot use __LINE__ to build a unique variable name in
a preprocessor macro.
#define BANK30 __attribute__((section("bank30")))
#define xxxprintf(fmt,...) { static char BANK30 fmt_ ## __LINE__[] = fmt;
printf(copy_format(fmt_ ## __LINE__), ##__VA_ARGS__); }
xxxprintf("hello, world\n");
This should have produced a variable named something linke fmt_57.
This arrose when trying to work around other gcc limitations (the inability
to specify a memory section on a string literal.
Fortunately, in this case, the enclosing braces should allow one to use a
non-unique name.
--
Summary: __LINE__ is not implemented in preprocessor
Product: gcc
Version: 3.2.2
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: preprocessor
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: whitis at freelabs dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16903
More information about the Gcc-bugs
mailing list