Reputation: 14052
I am confused by the following function definition without a compound statement in C:
void
__tu_finishme(const char *file, int line, const char *format, ...)
tu_printflike(3, 4);
It seems to not result in a function in generated object files, while the linker still expects __tu_finishme
to have been written.
Especially odd to me since
void
__tu_finishme(const char *file, int line, const char *format, ...) {
tu_printflike(3, 4);
}
seems to have different (AKA "normal") linkage than the former.
Can someone please explain which concept and niche of the C language I encounter here and how it works?
Bonus points for explaining things like:
void
foo(const char* c)
bar()
{
ha = hoo();
boo(ha);
}
Upvotes: 2
Views: 94
Reputation: 170065
tu_printflike
is very likely a macro that expands to an attribute like:
__attribute__ ((format (printf, 3, 4)))
The above is GCC specific, so the use of a macro is there to enable portability across compilers, it can be defined as something akin to
#ifdef __GNUC__
# define tu_printflike(i, j) __attribute__ ((format (printf, i, j)))
#else
# define tu_printflike(i, j)
#endif
Your bonus point can be explained just the same with
#define bar()
Where the definition is just an empty token sequence, the function like macro expands to nothing.
Upvotes: 3