Question

I'm trying to discover the meaning of some library linkage and found this in the header:

#ifndef LAPACK_GLOBAL
#if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_)
#define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
#elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER)
#define LAPACK_GLOBAL(lcname,UCNAME)  UCNAME
#elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE)
#define LAPACK_GLOBAL(lcname,UCNAME)  lcname
#else
#define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
#endif
#endif

I don't understand what these do, particularly where it is returning the suffixed ##_

Thanks

Was it helpful?

Solution

In the C preprocessor, ## is the token concatenation operator. So lcname##_ can be read as "create a new token by putting _ at the end of lcname".

I presume that the quoted preprocessor code is defining a preprocessor macro LAPACK_GLOBAL which is intended to be used as follows:

#define LAPACK_something LAPACK_GLOBAL(something, SOMETHING)

after which any use of LAPACK_something will be substituted by one of the following:

something
something_
SOMETHING

depending on the environment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top