-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow code annotations near preprocessor directives? #21
Comments
I briefly looked into it and found out that
Personal opinion: The |
Thanks for checking! I agree 100%. I think we only need to annotate very short strings that could easily be confused for pointer values or numbers. Is it reasonable to throw a syntax error if an annotation comes before a preprocessor statement? Once we get environment variables added to reccmp, the token-based parser will handle something like this and not alert to address reuse: #ifdef _DEBUG
// FUNCTION: HELLO 0x1234
void TestFunction() {
// debug version of the function
}
#else
// FUNCTION: HELLO 0x1234
void TestFunction() {
// regular version of the function
}
#endif Whether we want that sort of annotation syntax is perhaps another topic for discussion. |
If there is no way that the annotation will be processed correctly, imho yes. We could either throw a hard error or log a warning that this annotation is misplaced and cannot be processed. Both would be adequate in my eyes. |
If an annotation is not used or unexpected, I'd emit a warning (if the warning type is enabled): e.g. |
How about "emit warnings by default, fail on warnings when some flag is set"? I think one of our tools (decomplint?) already does that. |
Yes. The For reference, the WIP code for the tokenizer parser is here. The current design removes all preprocessor statements before handing the tokens off to the annotation parser. We could allow But if we ignore the implementation detail for a second, what should happen in general?
|
I would log a warning and ignore this particular annotation, which sounds like your option 2. |
isleapp.cpp has these two string annotations:
Should this be allowed? It's perfectly clear what is intended, but those lines are not "code" per se. Then again, we are not a compiler, so there's no requirement that these lines be excluded.
The text was updated successfully, but these errors were encountered: