'getenv' considered in MSVC as unsafe function#25
'getenv' considered in MSVC as unsafe function#25AwesomeTornado wants to merge 4 commits intoolrea:mainfrom
Conversation
|
Thanks @AwesomeTornado for your work. Your changes do work in Visual Studio but not for other platform. (the CI fails) I suggest two solutions:
#define _CRT_SECURE_NO_WARNINGS
#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif |
|
Thanks for the quick follow up! I think that using the pragma to disable the error when compiling with MSVC would be the best option, as it would require the least work from anyone using the library and would not suppress any errors elsewhere in someones code. |
|
It is recommended to add a wrapper function EnvValue to replace std::getenv.
|
The function "std::getenv()" is flagged as insecure in Visual Studio (why) , in order to fix this, I changed the functions to "_dupenv_s()" instead.
The code is still the same as before, just with a more secure function.
I tested the changes with one of the example programs, works exactly as before.