jasper-software / jasper

Official Repository for the JasPer Image Coding Toolkit
http://www.ece.uvic.ca/~mdadams/jasper
Other
217 stars 103 forks source link

Add <stdatomic.h> check to JAS_TRY_COMPILE_C11_THREADS #370

Closed BillyONeal closed 6 months ago

BillyONeal commented 6 months ago

In https://github.com/jasper-software/jasper/blob/b867d1adb2e6423c260407338bdc8d698330764e/src/libjasper/include/jasper/jas_thread.h#L87-L89 , JAS_THREADS_C11 assumes that both <threads.h> and <stdatomic.h> are available, but here, <stdatomic.h> is not checked. This causes builds with MSVC to fail with spew like:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(36): error C2061: syntax error: identifier 'atomic_bool'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(36): error C2059: syntax error: ';'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(37): error C2061: syntax error: identifier 'atomic_char'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(37): error C2059: syntax error: ';'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(38): error C2061: syntax error: identifier 'atomic_schar'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(38): error C2059: syntax error: ';'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(39): error C2061: syntax error: identifier 'atomic_uchar'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(39): error C2059: syntax error: ';'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(40): error C2061: syntax error: identifier 'atomic_short'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(40): error C2059: syntax error: ';'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(41): error C2061: syntax error: identifier 'atomic_ushort'
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.38.33130\include\vcruntime_c11_stdatomic.h(41): error C2059: syntax error: ';'

(MSVC 17.8 supports C atomics but it's behind a bunch of 'enable experimental things' switches right now, so including <stdatomic.h> without checking STDC_NO_ATOMICS fails like this)

Thanks to Charlie Barto and Casey Carter for helping me debug this.

BillyONeal commented 6 months ago

Thanks!