google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
34.51k stars 10.09k forks source link

Fix Windows compilation when _CRT_DECLARE_NONSTDC_NAMES=0 #4571

Open mon opened 3 months ago

mon commented 3 months ago

Closes #934 (which was closed due to inactivity, not due to it being fixed).

On Windows, using the POSIX names for some filesystem ops (chdir, fdopen, read, write, close) has been deprecated for some time (potentially as far back as the early to mid 90s).

Of course, Microsoft has kept the old names around for backwards compat for over 25 years. But when the above #define is set, (or when clang-cl is used with a /std: specified, apparently), the names are left undefined, causing compilation failures.

Considering how long the underscored names have been available, I consider this change to have no compatibility concerns.

mon commented 2 months ago

Apologies for the force push, I had a mistaken #if instead of #ifdef for one of the guards.