Menu

Line macro

Cyder

Line macro

The c11 standard describes a macro called __LINE__, that always expands to an integer constant for the current line.
It is a predefined macro, that cannot be undefined or redefined.

Hint: TPP uses the __LINE__ macro and its inherited inability, to be undefined as an include guard for files specifying #pragma once

// Print the current source line
printf("Line = %d\n",__LINE__);

#undef __LINE__ // Can't undef __LINE__
#ifdef __LINE__
// This block will still be enabled
#endif

s.a. [Conditional directives]
s.a. [Macros]


Related

Wiki: Counter macro
Wiki: Include level macro
Wiki: Line directive
Wiki: Pragma once

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.