Skip to content

Commit

Permalink
Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)
Browse files Browse the repository at this point in the history
MSVC's libc doesn't provide thread.h, so we should set the macro to
indicate that.

We could just set it in C mode, but I noticed that Darwin sets it
unconditionally, so perhaps we should do the same here.

Differential revision: https://reviews.llvm.org/D112081
  • Loading branch information
zmodem committed Dec 16, 2021
1 parent 8285522 commit bbc690c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/OSTargets.cpp
Expand Up @@ -203,6 +203,7 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) {
}

Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
Builder.defineMacro("__STDC_NO_THREADS__");

// Starting with VS 2022 17.1, MSVC predefines the below macro to inform
// users of the execution character set defined at compile time.
Expand Down
1 change: 1 addition & 0 deletions clang/test/Preprocessor/init.c
Expand Up @@ -195,6 +195,7 @@
// MSEXT-NOT:#define _NATIVE_WCHAR_T_DEFINED 1
// MSEXT-NOT:#define _WCHAR_T_DEFINED 1
// MSEXT:#define _MSVC_EXECUTION_CHARACTER_SET 65001
// MSEXT:#define __STDC_NO_THREADS__ 1
//
//
// RUN: %clang_cc1 -x c++ -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT-CXX %s
Expand Down

0 comments on commit bbc690c

Please sign in to comment.