4 ms·
One thing not mentioned here: it seems to me (though I'm not 100% sure) C++11 kind of wrecked macro preprocessing. Until it came along, I think you could ignore
by mehrdadn 6y ago
One thing not mentioned here: it seems to me (though I'm not 100% sure) C++11 kind of wrecked macro preprocessing. Until it came along, I think you could ignore C++ tokens and just pay attention to the preprocessor directives when figuring out e.g. what to #include, because strings couldn't span multiple lines, so you could easily identify the directives with a # in the beginning of the line. But C++11 introduced verbatim string literals, and it seems to me now you have to actually tokenize C++ constructs just to figure out how to do macro preprocessing. This means C++ preprocessing actually is a lexically different language than C preprocessing, which is kind of bewildering to me (notwithstanding more obvious differences like __cplusplus and such) and which means you can no longer e.g. just process the #include's without regard to the C++ tokens.
EDIT: Never mind, I'm wrong. Totally missed that line continuations can occur in quotes :(
- user982 6y ago> I think you could ignore C++ tokens and just pay attention to the preprocessor directives when figuring out e.g. what to #include, because strings couldn't span multiple lines, so you could easily identify the directives with a # in the beginning of the line. char *cstr = "This \ #is a valid " "C string"; If I understand you correctly, is this a counterexample?
- mehrdadn 6y agoAw shoot, yeah it is. :( Thanks!