-
Notifications
You must be signed in to change notification settings - Fork 1
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
Compiler warnings - sscanf - function or variable may be unsafe #17
Comments
It should also be noted that sscanf_s may be Microsoft specific and may break the current cross platform build |
Yes, it looks like it is. Need to look at this and determine if the use is safe, and the warning can be disabled, or if the warning is warranted, in which case case we can just define a wrapper for other platfforms. Need to determine what is the proper #ifdef to indicate running under the microsoft compiler |
I did some research (don’t have links handy) that showed you cannot just ifdef sscanf_s for sscanf. Different parameters. But one resource suggested the “right” way is to avoid scanf and use iostreams? Or std::string? or std::stringstream ? 🤷♂️ |
The signature is the same, so a #ifdef...#define should work. If the parameters were not the same, we could just define a wrapper method (i.e. implement "sscanf_s()" for other platforms). I did a quick test and simply replacing sscanf() with sscanf_s() works, however, it doesn't like this one line:
That warning looks wrong. Also, still need to identify the proper "#ifdef" for this compile environment. |
I found some clues in this dated article https://www.gamedev.net/forums/topic/564260-sscanf_s-in-linux-ubuntu/ may not even be relevant anymore |
STEPS:
EXPECTED:
no warnings
NOTES:
The exact warning
Example code:
''''
else if (sscanf(line, "ply %d %d", ¶m, ¶m2)==2)
''''
The code looks safe and sscanf() isn't really deprecated, so not a priority.
The text was updated successfully, but these errors were encountered: