On this page
func
Prev: typeof | Up: builtins | Next: __FILE__
Rel: __FILE__, __LINE__
Ref: cppreference — func
Tags: #public #prog #c #builtins #tier/core
Availability
Built-in (Predefined Identifier (C99)) — requires no #include header.
Syntax & Overview
static const char __func__[];
Function-local predefined identifier holding the name of the enclosing function as a NUL-terminated string.
Notes & Pitfalls
- Predefined
static const char[](C99), NOT a preprocessor macro: Cannot be concatenated with string literals ("in " __func__is a syntax error—pass it to%s).
Example
#include <stdio.h>
static void init(void) {
printf("entering %s\n", __func__);
}
int main(void) { init(); }
Linked from
Related notes
- tuts/c/builtins/__FILE__ 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/typeof 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