This is not clear from the question, but do you yourself generate the #line
directives given by source-line
and source-file
? Sorry, I am not familiar with Antlr.
Indeed, #line __LINE__ __FILE__
does nothing, but assigns the __LINE__
macro to itself.
Because of the semantics of preprocessor evaluation, you cannot easily assign a numerical value __LINE__
macro. (You can only define a new macro to map the __LINE__
macro literally, returning its current value.) But why do you need this? If Antlr itself does not use the __LINE__
macro, you do not need to restore it to its previous value.
If this is a problem, the easiest solution would be to put the C ++ source code in separate include
files and abandon the embedded attachment. To prevent the distribution of header files, you can use a construct like
$code #define USE_SNIPPET_FOO #include "snippets.h" $endcode $code #define USE_SNIPPET_BAR #include "snippets.h" $endcode
and in the header, the protection type of the return header:
#ifdef USE_SNIPPET_FOO #undef USE_SNIPPET_FOO class foo {}; #elif defined USE_SNIPPET_BAR #undef USE_SNIPPET_BAR class bar {}; #else #error no snippet selected #endif
source share