Skip to content

Commit

Permalink
Build with support for C11 atomics on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
calc84maniac committed Jan 11, 2024
1 parent a0951ad commit b5e0e01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* hacky atomics */
#if defined (MULTITHREAD)
#ifndef __cplusplus
#if !defined(__STDC_NO_ATOMICS__) && !defined(_MSC_VER)
#if !defined(__STDC_NO_ATOMICS__) || (defined(_MSC_VER) && _MSC_VER >= 1935)
#include <stdatomic.h>
#else
#define _Atomic(X) volatile X /* doesn't do anything, but makes me feel better... although if you are trying to do multithreading glhf */
Expand Down
6 changes: 5 additions & 1 deletion gui/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Sane flags
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# sane defaults + hardening
set(GLOBAL_COMPILE_FLAGS "-W -Wall -Wextra -Wno-unused-parameter -Werror=write-strings -Wredundant-decls -Werror=date-time -Werror=return-type -Werror=pointer-arith")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GLOBAL_COMPILE_FLAGS} -Werror=implicit-function-declaration -Werror=missing-prototypes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GLOBAL_COMPILE_FLAGS}")
# useful flags for debugging
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,bounds -fsanitize-undefined-trap-on-error ")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,bounds -fsanitize-undefined-trap-on-error ")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(MSVC_VERSION GREATER_EQUAL 1935)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /experimental:c11atomics")
endif()
endif()

include(GNUInstallDirs)
Expand Down

0 comments on commit b5e0e01

Please sign in to comment.