Open jmelas opened 3 years ago
I think ten years is adequate time to update to a new standard.
We're using C89 not C99. We need to stick to a common subset that MSVC supports.
In September 2020, Microsoft announced preliminary C11 support: https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/
I think we need to wait another 10 years.
Phil and I discussed this:
To continue to support even reasonably recent MSVC, we need to continue with C89 for common code and shared header files.
That said, we should probably use C11 atomics where available (see #663 for a compile-time detection method), along with a fallback (i.e. the current code) for older compilers. This is covered by #675 I think.
The only tractable alternative to using C89 everywhere seems to be that we could consider allowing C99 or C11 for host API implementations on Mac and Unix. We already use C++03 for pa_asio.cpp.
Personally I'm not keen to balkanize the code base and use C89 in some places and C99 or C11 in other places. This will be confusing to maintain.
A reasonable proposal derailed by Microsoft's lackluster standards compliance. :(
The only tractable alternative to using C89 everywhere seems to be that we could consider allowing C99 or C11 for host API implementations on Mac and Unix. We already use C++03 for pa_asio.cpp. Personally I'm not keen to balkanize the code base and use C89 in some places and C99 or C11 in other places. This will be confusing to maintain.
It could be maintained automatically by CI if the C standard version is enforced by the build system.
It seems on mac we already use c99? See file configure CFLAGS="-std=c99 $CFLAGS $mac_arches $mac_sysroot $mac_version_min"
I will try putting a C99 construct into the common code and see if it breaks out GitHub CI.
In #663, we use C11 for the CMake build on Mac. This was so we could use atomic_thread_fence() to fix deprecation warnings.
Is there any reason to still use C99? By moving to C11 we gain access to
<stdatomic.h>
and<threads.h>
For example issue #573 could use_ThreadLocal
as @philburk suggested. If we agree, I am happy to create a PR that upgrades to C11 support.