Open AwesomeTornado opened 1 year ago
Thanks @AwesomeTornado for your work. Your changes do work in Visual Studio but not for other platform. (the CI fails)
I suggest two solutions:
We comment that in the README troubleshooting section to warn people using MSVC and having this error. Hence we can keep the current implementation (std::get_env) and we suggest to define the following at compilation:
#define _CRT_SECURE_NO_WARNINGS
We ignore the getenv warning with something like:
#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.
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.