Open mcilloni opened 8 months ago
The preprocessor says that bit of code looks like this:
#line 10 "C:/data/msvc/14.38.33133/include\\threads.h"
#pragma warning(push)
#pragma warning(disable : _UCRT_DISABLED_WARNINGS)
_UCRT_DISABLE_CLANG_WARNINGS
__pragma(pack(push, 8))
But I have no idea what it's supposed to look like or if this compiler supports that header file.
The preprocessor says that bit of code looks like this:
#line 10 "C:/data/msvc/14.38.33133/include\\threads.h" #pragma warning(push) #pragma warning(disable : _UCRT_DISABLED_WARNINGS) _UCRT_DISABLE_CLANG_WARNINGS __pragma(pack(push, 8))
But I have no idea what it's supposed to look like or if this compiler supports that header file.
MSVC has fully supported C11 Threads since last September. It is part of the standard C library, and both CL and Clang compile that snippet fine with the latest stable MSVC runtime.
threads.h
starts with
// Copyright (c) Microsoft Corporation. All rights reserved.
#pragma once
#define _THREADS_H
#include <vcruntime.h>
#include <corecrt.h>
#include <stdint.h>
#include <time.h>
#pragma warning(push)
#pragma warning(disable : _UCRT_DISABLED_WARNINGS)
_UCRT_DISABLE_CLANG_WARNINGS
_CRT_BEGIN_C_HEADER
#ifndef __cplusplus
#define thread_local _Thread_local
#endif
but it does not look any different to me from any other UCRT header honestly.
The workaround is this: https://godbolt.org/z/coYh6PrE5
So I defined the missing defines from some randomly googled source, but I'm not sure why they are missing as soon as you include threads.h and not when including other headers.
I also had to "disable unknown pragma warnings" with #pragma warning(disable:4068)
because apparently 'clang' is not a known pragma at this point, also strange.
It looks like now with our hosted msvc we're getting
<source>(3): fatal error C1083: Cannot open include file: 'threads.h': No such file or directory
it doesn't appear to be part of compiler's default installation, we'll have to see if it shows up on later versions, or that maybe it's part of an extra module
Describe the bug
I've noticed that MSVC (both ARM and X64) does not build cleanly whenever
threads.h
is included (with the/std:c11
flag on):This code builds cleanly on CL 19.38 with the
/std:c11
flag, but fails to build on Compiler Explorer (both MSVC 19.38 and latest) with:I guess that that
#define
is somehow breakingthreads.h
and preventing this snippet from parsing?Thanks a lot and keep up the great work btw!
Steps to reproduce
msvc v19.38
, either x64 or arm64Expected behavior
The snippet compiles cleanly, like it does locally when running
cl.exe /std:c11 file.c
Reproduction link
https://godbolt.org/z/rheE8rPdv
Screenshots
Not applicable
Operating System
No response
Browser version
Firefox 123.0