My understand is that __func__ is not a keyword and that is something defined inside the functions.. so I don’t know why gcc and clang
complains in the file scope.
"The identifier __func__ shall be implicitly declared by the translator
as if, immediately following
the opening brace of each function definition, the declaration" ...
__func__ is just an string that has name of the function it is in,
so for example:
#include <stdio.h>
int
main(int argc, char** argv) {
printf("we are on: %s\n", __func__);
return 0;
}
Will print:
we are on: main
My understand is that __func__ is not a keyword and that is something
defined inside the functions.. so I don’t know why gcc and clang
complains in the file scope.
Yes, it is a sort of atomic identified reserved by the compiler.
You can't redefine it, just like any normal identifier, if that
makes sense. The compiler errors are from C not understanding
the code.
"The identifier __func__ shall be implicitly declared by the translator
as if, immediately following
the opening brace of each function definition, the declaration" ...
What it refers to is:
type
myfunction(...) { // <--- from here on, __func__ is available.
...
}
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,113 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 492402:19:44 |
| Calls: | 14,249 |
| Files: | 186,315 |
| D/L today: |
84 files (21,992K bytes) |
| Messages: | 2,515,139 |