File: flex.info, Node: Global Replacement, Next: Init and Destroy Functions, Prev: Extra Reentrant Argument, Up: Reentrant Detail 19.4.3 Global Variables Replaced By Macros ------------------------------------------ In the C/C++ back end global variables in traditional flex have been replaced by macro equivalents. Be aware that this will not be true in target languages without macros, so relying on this backward-compatibility hack will hinder forward portability. Accordingly, in the above example, 'yyout' and 'yytext' are not plain variables. These are macros that will expand to their equivalent lvalue. All of the familiar 'flex' globals have been replaced by their macro equivalents. In particular, 'yytext', 'yyleng', 'yylineno', 'yyin', 'yyout', 'yyextra', 'yylval', and 'yylloc' are macros. You may safely use these macros in actions as if they were plain variables. We only tell you this so you don't expect to link to these variables externally. Currently, each macro expands to a member of an internal struct, e.g., in C/C++: #define yytext (((struct yyguts_t*)yyscanner)->yytext_r) One important thing to remember about 'yytext' and friends is that 'yytext' is not a global variable in a reentrant scanner, you can not access it directly from outside an action or from other functions. You must use an accessor method, e.g., 'yyget_text', to accomplish this. (See below).
