On this page
LINE
Prev: __FILE__ | Up: builtins | Next: __STDC_VERSION__
Rel: __FILE__, __func__
Ref: cppreference — LINE
Tags: #public #prog #c #builtins #tier/core
Availability
Built-in (Predefined Macro) — requires no #include header.
Syntax & Overview
__LINE__
Expands to an integer constant representing the current line number in the source file.
Notes & Pitfalls
- Expands to the current 1-based integer line number: Always evaluate inside a macro at the call site, not inside a helper function.
Example
#include <stdio.h>
#define LOG(msg) fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, (msg))
int main(void) { LOG("ready"); }
Linked from
Related notes
- tuts/c/builtins/__FILE__ Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__func__ Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__STDC_VERSION__ Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins Linked here; links to this page; shared tags: #builtins, #c, #prog
- tuts/c/builtins/_Alignof shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Atomic shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Generic shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Noreturn shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Static_assert shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Thread_local shared tags: #builtins, #c, #prog, #tier