Closed Helmta closed 3 years ago
Hi @Helmta. If the compiler is detected as clang, the C/C++ extension currently detects whether ms-extensions
is enabled by detecting a define emitted by the compiler: _MSC_EXTENSIONS
. This define is required to be set when ms-extensions
is enabled. (Though, it's specifically associated with C compilation. Does your compiler not support C compilation?). We do this because it's not necessary to pass -fms-extensions
to enable the feature. It can also become enabled by default (depending on current platform) or enabled based on a specified target. (i.e. --target
arg). It sounds like you using a clang-derived compiler that has either removed the associated define, or is ignoring the -fms-extension
passed to it (either by default, or based on other arguments).
If your compiler supports C compilation, this would seem to be a bug with the compiler not specifying a define associated with the feature.
Could you provide the output of the following 2 commands? (or a diff of the defines it outputs?)
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c11 -Wp,-v -E -dD -x c -fno-blocks nul
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fno-ms-extensions -std=c11 -Wp,-v -E -dD -x c -fno-blocks nul
I'm curious if that might provide some evidence of whether that compiler is recognizing the arg or ignoring it.
If the first one has _MSC_EXTENSIONS
in the output, I'm curious if it get omitted by:
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -fno-blocks nul
Hi,
thanks for the hint with the _MSC_EXTENSIONS
.
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c11 -Wp,-v -E -dD -x c -fno-blocks nul
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fno-ms-extensions -std=c11 -Wp,-v -E -dD -x c -fno-blocks nul
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -fno-blocks nul
do not have _MSC_EXTENSIONS
in theirs outputs.
Ouputs of C are the same
Output of C++
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -fno-blocks nul
You can see the line
clang -cc1 version 5.0.2 based upon LLVM 5.0.2 default target i686-pc-windows-msvc
in the output.
So I played a bit with the commenadline args. Especially the -target
option was interesting.
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -target=x86_64-pc-win32-elf -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -fno-blocks nul
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" "-triple x86_64-pc-win32-elf" -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -fno-blocks nul
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -triple=x86_64-pc-win32-elf -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -fno-blocks nul
has the same output as
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -fno-blocks nul
The only way i found to get the _MSC_EXTENSIONS
defined is with -cc1
option and -fms-extensions
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -cc1 -fms-extensions -std=c++17 -E -dD -x c++ nul
Then i have to set the target with -triple <value>
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -cc1 -triple x86_64-pc-win32-elf -fms-extensions -std=c++17 -E -dD -x c++ nul
So I tried to set -cc1
in the settings but it is ignored.
or
With
"C_Cpp.default.compilerPath": "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe -cc1 -fms-extensions",
-cc1
and -fms-extensions
are just ignored.
C:\WINDOWS\system32>bcc64 -cc1 -version
LLVM (http://llvm.org/):
LLVM version 5.0.2
DEBUG build.
Default target: i686-pc-windows-msvc
Host CPU: skylake
C:\WINDOWS\system32>bcc64 --version
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc.
Embarcadero Technologies Inc. bcc64 version 5.0.2 (36933.9854b07.fc1c373) (based on LLVM 5.0.2)
Target: x86_64-pc-windows-elf
Thread model: posix
InstalledDir: C:\prg\Embarcadero\Studio\20.0\bin
stripped commandline with all args the original GUI is invoking
"C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -cc1 -dwarf-version=2 -fborland-extensions -fdiagnostics-format borland -nobuiltininc -nostdsysteminc -triple x86_64-pc-win32-elf -emit-obj -fexceptions -fcxx-exceptions -fseh -munwind-tables -fno-common -fno-spell-checking -fno-use-cxa-atexit -x c++ -std=c++17 -O2 -fmath-errno -tR -tD -tM -tU -PD -sys-header-deps -E -dD -x c++ nul
This does not define _MSC_EXTENSIONS
either. But it works and cmake does the job too even without the -cc1
option.
Hi @Helmta . Does your code include uses of MS extensions that fail to compile when -fms-extensions
is not specified? If so, I believe we can fix this by falling back to checking the compiler argument if the define is not found.
I'm not familiar with either the -cc1
or triple
arguments. I don't see them specified on either:
That would explain why we are not processing them. Can you refer me to documentation that describes them? We should be able to fix the issue with -cc1
not being passed through, but I could use more info on the format of the value passed to -triple
. Is it the same as --target
?
Using clang (9, 10, 11, 12), I haven't been able to get it to accept a -triple
arg. I get:
clang: error: unknown argument: '-triple'
Is that something unique to Embarcadero C++ ? The form appears to be the same as --target
.
Hi @Colengms .
Does your code include uses of MS extensions that fail to compile when -fms-extensions is not specified? If so, I believe we can fix this by falling back to checking the compiler argument if the define is not found.
The code compiles without problems. I think that -fms-extensions
is set somewhere implicitly. The fallback would be great.
I'm not familiar with either the -cc1 or triple arguments. I don't see them specified on either:
I have not found any documentation either. The only way is throuh clang -help
and compare the output to clang -cc1 -help
.
-cc1
has to be the very first argument. So -triple
works only with -cc1
: clang -cc1 -triple <value>
and i think it is the same as --target
https://stackoverflow.com/questions/8991662/what-does-the-clang-cc1-option-do
This explains what -cc1
does.
Thanks for ur great help. I will be on vacation for 10 days, so i can not answer.
The code compiles without problems. I think that -fms-extensions is set somewhere implicitly. The fallback would be great.
Hi @Helmta . I'd like to confirm that the compiler is actually supporting -fms-extensions
and not ignoring the arg, before I add support for this scenario. Does your code compile if -fno-ms-extensions
is passed instead? If so, it's possible the lack of expected define is due to the feature not actually being enabled.
-cc1
provides access to clang's internal, undocumented args that are passed directly to its compiler layer instead of being processed by the GCC compatibility layer. The C/C++ extension currently supports only the args for the GCC compatibility layer. I've opened the following feature request to add support for internal clang args: https://github.com/microsoft/vscode-cpptools/issues/7900
Hi @Colengms .
I tested both clang and bcc64 compiler with testcode. I can confirm that clang is working as expected and bcc64 is ignoring the
options -fms-extensions
and -fno-ms-extensions
.
It compiles successfully, so I think the ms-extensions are enabled by default without setting the define.
Test.cpp:
__declspec(dllexport) void TestFunction(int const test) { auto newTest = test; }
D:\PGA>clang -fno-ms-extensions -c test.cpp
test.cpp:1:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes __declspec(dllexport) void TestFunction(int const test) ^ 1 error generated.
D:\PGA>bcc64 -fno-ms-extensions -c test.cpp
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc. bcc64.exe: warning: argument unused during compilation: '-fno-ms-extensions' [-Wunused-command-line-argument]
test.cpp:
D:\PGA>bcc64 -fms-extensions -c test.cpp
Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc. bcc64.exe: warning: argument unused during compilation: '-fms-extensions' [-Wunused-command-line-argument]
test.cpp:
If I use the -cc1
option, I need to activate the ms-extensions.
D:\PGA>bcc64 -cc1 test.cpp
test.cpp:3:1: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes __declspec(dllexport) void TestFunction(int const test) ^ test.cpp:5:3: warning: 'auto' type specifier is a C++11 extension auto newTest = test; ^ 1 warning and 1 error generated.
D:\PGA>bcc64 -cc1 -fms-extensions test.cpp
test.cpp:5:3: warning: 'auto' type specifier is a C++11 extension auto newTest = test; ^ 1 warning generated.
D:\PGA>bcc64 -cc1 -fno-ms-extensions test.cpp
error: unknown argument: '-fno-ms-extensions'
I tested more code with the original GUI and it is allways invoking the compiler with the -cc1
option.
This should be addressed in 1.6.0-insiders.
Note that was addressed by honoring the arg if present on the command line, not by hard-coding awareness of bcc64
(which may be a better solution). Also, because -cc1
is not yet supported (https://github.com/microsoft/vscode-cpptools/issues/7900), I'd suggesting passing it without -cc1
(as it should be ignored by the compiler when queried).
Bug type: Language Service
VS-Code Version: 1.58.2 (system setup) OS: Windows_NT x64 10.0.18363
Hi, we are using Embarcadero C++ Builder 10.3 as our C++ compiler. It's a clang-based compiler. We are using cmake+ninja for compilation and it works but we can not use cmake as configuration-provider.
relevant setting:
"C_Cpp.default.intelliSenseMode": "windows-clang-x64", "C_Cpp.default.cppStandard": "c++17", "C_Cpp.default.cStandard": "c11", "C_Cpp.default.systemIncludePath": [ "C:/prg/Embarcadero/Studio/20.0/include/dinkumware64/", "C:/prg/Embarcadero/Studio/20.0/include/boost_1_68/", "C:/prg/Embarcadero/Studio/20.0/include/windows/" ], "C_Cpp.default.configurationProvider": "${default}", //suppress cmake asking for intellisense-provider on every startup "C_Cpp.default.compilerPath": "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe", "C_Cpp.default.compilerArgs": [ "-fms-extensions" ], "C_Cpp.intelliSenseEngine": "Default",
With C/C++ Version 1.3.1
C/C++ Logs in Debug-Mode: Attempting to get defaults from C compiler in "compilerPath" property: 'C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe' Querying compiler for default C++ language standard using command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -x c++ -E -dM nul Custom configuration provider 'CMake Tools' registered Detected language standard version: c++17 Querying compiler for default C language standard using command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -x c -E -dM nul Detected language standard version: c11 Querying compiler's default target using command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -dumpmachine Compiler returned default target value: Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc. x86_64-pc-windows-elf
Compiler query command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c11 -Wp,-v -E -dD -x c -m64 -fno-blocks nul Code browsing service initialized Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe' Compiler query command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -m64 -fno-blocks nul ... other: --ms_extensions other: --clang other: --clang_version=50002 stdver: c++17 intelliSenseMode: windows-clang-x64 ...
Logs after trying to switch to "windows-gcc-x64": [28.7.2021, 09:39:01] For C source files, IntelliSenseMode was changed from "windows-gcc-x64" to "windows-clang-x64" based on compiler args and querying compilerPath: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" [28.7.2021, 09:39:03] For C++ source files, IntelliSenseMode was changed from "windows-gcc-x64" to "windows-clang-x64" based on compiler args and querying compilerPath: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe"
With C/C++ Version 1.5.1 (every Version after 1.3.1)
Attempting to get defaults from C compiler in "compilerPath" property: 'C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe' Querying compiler for default C++ language standard using command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -x c++ -E -dM nul Detected language standard version: c++17 Querying compiler for default C language standard using command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -x c -E -dM nul Detected language standard version: c11 Querying compiler's default target using command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -dumpmachine Compiler returned default target value: Embarcadero C++ 7.40 for Win64 Copyright (c) 2012-2018 Embarcadero Technologies, Inc. x86_64-pc-windows-elf
Compiler query command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c11 -Wp,-v -E -dD -x c -m64 -fno-blocks nul Code browsing service initialized Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe' Compiler query command line: "C:/prg/Embarcadero/Studio/20.0/bin/bcc64.exe" -fms-extensions -std=c++17 -Wp,-v -E -dD -x c++ -m64 -fno-blocks nul Custom configuration provider 'CMake Tools' registered ... --->at this point "other: --ms_extensions" is missing <--- other: --clang other: --clang_version=50002 stdver: c++17 intelliSenseMode: windows-clang-x64 ...