-
Notifications
You must be signed in to change notification settings - Fork 408
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
Compiling in VS 2015 as C++ #37
Comments
I've addressed your first issue in a portable manner. The second one is trickier, since people do not seem to agree on what a bounded Since there is no risk of overflow here, I would probably suggest using the |
Does that macro have to be applied globally, or can it be applied per source file? I'm of the mind set that if only a small piece of code throws a security warning, you don't disable that warning for the whole project if it could potentially come up elsewhere in later code changes. I would agree, in this context, the buffers in question are well contained in code that is not externally or user accessible so the risk is low. |
I will also add, in encoding.c and run.c, there are warnings thrown when compiling as x64 instead of Win32, that storing a These are in the definitions of |
Macro only needs to be applied locally; e.g., put I've fixed the warning in |
Microsoft seems to have two specific beefs with the code as it exists now. Everything else compiles without warning or issue:
1 encoding.c, the definition for EQ(x, y), throws C4146 which prevents compilation
https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(C4146)&rd=true
In order to compile the code I suppress the warning each time it comes up, as I don't know a way around this.
#pragma warning(suppress: 4146)
2 encoding.c, the definition for SX(x) uses sprintf which Microsoft deems unsafe (and prevents compilation), so they recommend using sprintf_s which includes a buffer length (4 parameters instead of 3) to allow for safety checks inside the function itself. Easy fix.
#define SX(x) \ do { \ char tmp[30]; \ sprintf_s(tmp, 30, "%lu", (unsigned long)(x)); \ SS(tmp); \ } while (0)
The text was updated successfully, but these errors were encountered: