adeharo9 / cpp-dotenv

Loads environment variables from .env files for C++ projects.
BSD 3-Clause "New" or "Revised" License
88 stars 21 forks source link

The change to directly call setenv makes the code POSIX-specific #15

Closed LewisWolfgang closed 4 years ago

LewisWolfgang commented 4 years ago

Windows, for example, does not have setenv(). It is, of course, possible to implement setenv() on Windows using _putenv_s..., but perhaps something should be noted in the documentation.

adeharo9 commented 4 years ago

Yes, it is true; thankfully, as far as I know it is the only POSIX-specific trait of the project. It shouldn't be much of a hustle to add support to Windows.

By the moment, I'll leave the issue opened; I'm planing on working again on this project this summer, so I'll try to have it fixed by the end of it.

adeharo9 commented 4 years ago

I've added some Windows-specific code to define the setenv symbol using the POSIX specification and the secure versions of the Windows API (getenv_s and _putenv_s). As far as I know, now all POSIX-compliant (linux, MacOS, etc.) and Windows systems should be supported.

Haven't been able to test it on Windows so far though, and won't be able for some time. I've added the change to dev so it is added on the next release. I'll try to have it tested by then.

Closing the issue meanwhile.