Menu

Counter macro

Cyder

Counter Macro

Config: #define TPP_CONFIG_HAVE___COUNTER__ 0/1
Check: #if defined(__COUNTER__)
Function: tpp.c: TPPLexer_Next
Known supporting compilers: vc, gcc, clang

A builtin macro, that expands to and integral constant similar to __LINE__, but instead of yielding the current line, it will yield an ever-incrementing number, that starts at 0 when the lexer is initialized.

The following example show the counter macro expanding to different values every time it is called.

// Assuming begin of preprocessor file
__COUNTER__ // Expands to [0]
__COUNTER__ // Expands to [1]
__COUNTER__ // Expands to [2]

s.a. [Line macro]
s.a. [Bracket notation]


Related

Wiki: Bracket notation
Wiki: Line macro

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.