question

Renishug-8451 avatar image
0 Votes"
Renishug-8451 asked Renishug-8451 commented

IntelliSense in a Visual Studio 2019 Makefile project assumes C++ but my files are C

Visual Studio 2019, V16.11.4

If I create a Makefile project, then add a C file, say main.c, to it, IntelliSense teats that file as a C++ file, not a C file, which is leading to IntelliSense squiggles that really should not be there.

I can tell that the file is being treated as C++ because if I enable Diagnostic Logging, with Level 5 and Filter 8, the output is:

<9448> [IntelliSense] command line options:
/c
/W1
/WX-
/DWIN32
/D_DEBUG
/EHsc
/MDd
/fp:precise
/Zc:wchar_t
/Zc:forScope
/ifcOutputDebug\\
/FoDebug\\
/Gd
/errorReport:prompt
/TP
/IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include
/IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\include
/IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\VS\include
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt
/IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\Include\um
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\VS\lib\x86
/AIC:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x86
/AIC:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x86
/AIC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86
/BCDC:\Users\xxxxxxxx\source\repos\MakefileProjectTest
C:\USERS\xxxxxxxx\SOURCE\REPOS\MAKEFILEPROJECTTEST\MAIN.C
/AutoPCHC:\Users\xxxxxxxx\source\repos\MakefileProjectTest.vs\MakefileProjectTest\v16\ipch\AutoPCH\c899e3138a898b7c

Key in these command line options is "/TP", which means 'treat all files as C++'.

If I open the project Properties, go to the NMake Configuration Property, and add /TC /std:c11 to the "Additional Options" entry for IntelliSense, then the above becomes,

<9448> [IntelliSense] command line options:
/c
/W1
/WX-
/DWIN32
/D_DEBUG
/EHsc
/MDd
/fp:precise
/Zc:wchar_t
/Zc:forScope
/ifcOutputDebug\\
/FoDebug\\
/Gd
/errorReport:prompt
/TC
/std:c11
/TP
/IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include
/IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\include
/IC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\VS\include
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt
/IC:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt
/IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\Include\um
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\atlmfc\lib\x86
/AIC:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\VS\lib\x86
/AIC:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x86
/AIC:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x86
/AIC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86
/BCDC:\Users\xxxxxxxx\source\repos\MakefileProjectTest
C:\USERS\xxxxxxxx\SOURCE\REPOS\MAKEFILEPROJECTTEST\MAIN.C
/AutoPCHC:\Users\xxxxxxxx\source\repos\MakefileProjectTest.vs\MakefileProjectTest\v16\ipch\AutoPCH\c899e3138a898b7c

The "/TC /std:c11" has appeared, as expected, but the "/TP" is still there and appears to 'win'. A keyword of C11, _Noreturn, is being given a squiggly when I use it (correctly) in main.c. I would like to get rid of the "/TP" command line option but it is being added behind the scenes. Is there a way for me to be able to alter this?

vs-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @Renishug-8451
I suggest you can start a new thread and report this issue to VS Product Team in our Developer Community with some reproduced or detailed information. if you do report this issue, please share the link here, other forum members who are interested or meet the same or similar issue can go to vote for this thread.


0 Votes 0 ·

A good suggestion. I just wanted to wait a bit to see if anyone had a way of working around this, but since nothing forthcoming I reckoned this was worth reporting in the Developer Community: 1562893


0 Votes 0 ·

1 Answer

RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered RLWA32-6355 commented

According to tc-tp-tc-tp-specify-source-file-type specifying /Tc filename on the command line will override the /TP global option.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Many thanks for taking the trouble to respond. Unfortunately, I am wanting IntelliSense to work properly over the whole of my codebase, which is made up entirely of C files.

Out of interest, I specified both /TP and /Tcmain.c in a normal project (as opposed to a Makefile project) and main.c was compiled as C++, so /Tc was not overriding /TP. Using Detailed for the 'MSBuild project build output verbosity' the actual command line showed both options, with the order of them being /TP then /Tcmain.c. order-of-cl-options says "If CL encounters conflicting options, it uses the rightmost option", so on two counts /Tcmain.c should have been respected over /TP.

I also tried adding /Tcmain.c on my 'toy' Makefile project and seeing if it sorted out the IntelliSense issue that I am having, but it did not.

So /Tc turns out not to be a workaround for the issue that I am having.


0 Votes 0 ·

Sounds like you found a bug that might be worth reporting.

0 Votes 0 ·

I agree; I've reported /Tc not overriding /TP: 1555550.


0 Votes 0 ·
Show more comments