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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It means that
YY_DECLwill be expanded toThis is actually C++, not C; when you compile this file with a C++ compiler, it declares that the function
yylexmust 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 __cplusplusaround this#define; that’s a special macro used to indicate compilation by a C++ compiler.