On this page
FILE
Prev: __func__ | Up: builtins | Next: __LINE__
Rel: __LINE__, __func__
Ref: cppreference — FILE
Tags: #public #prog #c #builtins #tier/core
Availability
Built-in (Predefined Macro) — requires no #include header.
Syntax & Overview
__FILE__
Expands to a string literal containing the presumed name of the current source file.
Notes & Pitfalls
- Expands to the current source filename string literal: Combine with
__LINE__and__func__in logging/assertion macros.
Example
#include <stdio.h>
int main(void) {
fprintf(stderr, "[%s:%d] started\n", __FILE__, __LINE__);
}
Linked from
Related notes
- tuts/c/builtins/__func__ Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__LINE__ 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/__STDC_VERSION__ shared tags: #builtins, #c, #prog, #tier
- 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