olrea / openai-cpp

OpenAI C++ is a community-maintained library for the Open AI API
https://openai.com/api/
MIT License
195 stars 66 forks source link

'getenv' considered in MSVC as unsafe function #25

Open AwesomeTornado opened 1 year ago

AwesomeTornado commented 1 year ago

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.

coin-au-carre commented 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:

See https://stackoverflow.com/a/66090653/2352158

AwesomeTornado commented 1 year ago

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.