Function assignment in C: parentheses in function names

I read the source code when I saw my names with names in parentheses:

extern int LIB_(strcmp) ( const char* s1, const char* s2 );
extern char LIB_(tolower) ( char c );

What is it?

I got confused because I could call 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 perform type casting?

+3
source share
3 answers

This is really confusing. LIB_(x)is a macro defined somewhere that evaluates the real name of a function.

Thus, the function name is not actually LIB_(strcmp), but the result of the macro LIB_(x). Most likely, it is LIB_(x)intended to add the library name / identifier to the beginning of the function and is defined as follows:

/* prepend libname_ onto the name of the function (x) */
#define LIB_(x) libname_ ## x
+8
source

, , LIB_(strcmp). - LIB_ ; , , , .

( ).

+1

I believe that LIB_is a macro defined somewhere.

0
source

All Articles