I was reading a source code when I saw functions with parentheses in their names:
extern int LIB_(strcmp) ( const char* s1, const char* s2 );
extern char LIB_(tolower) ( char c );
What is that?
I am confused because I could call the functions like this: char c = LIB_(tolower)('A');
Isn't it true that in C, parentheses are used to separate function names from parameters and to do type casting?
This is indeed confusing. LIB_(x)
is a macro defined somewhere, which evaluates to the real name of the function.
So the function's name is not actually LIB_(strcmp)
but the result of the LIB_(x)
macro. Most likely, LIB_(x)
is intended to prepend a library name/identifier onto the beginning of the function and is defined like this:
/* prepend libname_ onto the name of the function (x) */
#define LIB_(x) libname_ ## x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With