boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

252-line-in-macro.c (576B)


      1 /* `__LINE__` inside a macro body must report the line of the macro
      2  * INVOCATION, not the line of the `#define` (C11 ยง6.10.8.1). The
      3  * implementation kept body tokens' original locations across
      4  * substitution; %pp-expand-builtin then read the body line, so
      5  * HERE expanded with the body's line (the `#define` line) instead
      6  * of the call site.
      7  */
      8 
      9 #define HERE __LINE__
     10 
     11 int main(void) {
     12     int a = HERE;  /* this is line 12 */
     13     int b = HERE;  /* this is line 13 */
     14     if (a != 12) return 1;
     15     if (b != 13) return 2;
     16     if (b - a != 1) return 3;
     17     return 0;
     18 }