Skip to content
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

#pragma message w/ #include result in error #27

Open
PaltryProgrammer opened this issue Oct 31, 2022 · 5 comments
Open

#pragma message w/ #include result in error #27

PaltryProgrammer opened this issue Oct 31, 2022 · 5 comments

Comments

@PaltryProgrammer
Copy link

Greetings Kind Regards The statements below cause problems for checkheaders. In particular the code threw a std::out_of_range exception. It finds #include 'ed stdafx.h") which of course it does not wish to. I utilize such #pragma messages to aid in debugging. I am not certain but perhaps regex or awk would be better choices. Thank You Kindly

#include "stdafx.h"
#pragma message (#include 'ed stdafx.h")

@danmar
Copy link
Owner

danmar commented Nov 2, 2022

Thanks! I appreciate you report this issue however I don't actively maintain this tool anymore. If you make a fix in a PR I could merge it.

So how does this #pragma message works.. all inside the () should be treated as some raw string? If there is a ) in the text what happens then?

For information instead of #pragma message you could write #warning ... that is a standard preprocessor command so it's portable.

@PaltryProgrammer
Copy link
Author

PaltryProgrammer commented Nov 2, 2022

Greetings Kind Regards I made the change below on line 267 of tokenize.cpp I do not know if it breaks anything. However upon using checkheaders it reported many files not needed which were in fact needed so perhaps I did break it or checkheaders is faulty. As for #pragma message I only know what is found here #pragma message - Best
else
{
// bpw - my initials
std::string skip_this_line;
getline(code, skip_this_line);
lineno++;
// addtoken(line.c_str(), lineno, FileIndex);
// pToken = CurrentToken;
// std::memset(CurrentToken, 0, sizeof(CurrentToken));
}

@danmar
Copy link
Owner

danmar commented Nov 3, 2022

When I read the help text it sounds to me like msvc expects the parameter to be a message string. i.e.

#pragma message ("#include \"stdafx.h\"")

does it compile your example code and it works as expected?

@PaltryProgrammer
Copy link
Author

PaltryProgrammer commented Nov 6, 2022 via email

@danmar
Copy link
Owner

danmar commented Nov 6, 2022

That looks like valid code:
#pragma message( "#include " __FILE__ )

But I don't think this looks valid: #pragma message (#include 'ed stdafx.h")

Shouldn't it be: #pragma message ("#include 'ed stdafx.h")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants