In some Bison code, what does the following line mean?
#define YY_DECL extern "C" int yylex();
I know #define command but I don't understand the whole command.
It means that YY_DECL will be expanded to
extern "C" int yylex();
This is actually C++, not C; when you compile this file with a C++ compiler, it declares that the function yylex must be compiled with "C linkage", so that C functions can call it without trouble.
If you don't program in C++, this is largely irrelevant to you, but you may encounter similar declarations in C header files for libraries that try to be compatible with C++. C and C++ can be mixed in a single program, but it requires such declarations for function to nicely work together.
There's probably an #ifdef __cplusplus around this #define; that's a special macro used to indicate compilation by a C++ compiler.
#define YY_DECL extern "C" int yylex();
Define a macro YY_DECL standing for the declaration of a function yylex that has 'C' linkage inside a C++ program, taking no arguments and returning an int.
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