When picking the "Release" variant, the #ifndef NDEBUG check is graying out the else block instead (see image below). However, it does include the correct block of code on compilation.

Can you run the "C/C++: Log Diagnostics" command and paste the output here?
-------- Diagnostics - 18/11/2019, 22:54:49
Version: 0.26.1
Current Configuration:
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:\\Users\\STEVEN~1\\scoop\\shims\\clang-cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"compilerArgs": [],
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Translation Unit Mappings:
[ C:\Users\Steven Upton\Workspace\tearex\main.cpp ]:
C:\USERS\STEVEN UPTON\WORKSPACE\TEAREX\MAIN.CPP
C:\VULKANSDK\1.1.126.0\INCLUDE\VULKAN\VULKAN_CORE.H
Translation Unit Configurations:
[ C:\Users\Steven Upton\Workspace\tearex\main.cpp ]:
Process ID: 10792
Memory Usage: 147 MB
Compiler Path: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
Includes:
C:\VULKANSDK\1.1.126.0\INCLUDE
C:\USERS\STEVEN UPTON\WORKSPACE\TEAREX\INC
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.23.28105\INCLUDE
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.23.28105\ATLMFC\INCLUDE
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UM
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UCRT
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\SHARED
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\WINRT
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\CPPWINRT
Defines:
_DEBUG
UNICODE
_UNICODE
Standard Version: ms_c++17
IntelliSense Mode: msvc-x64
Total Memory Usage: 147 MB
Thanks! It looks like you're using compile_commands.json to configure IntelliSense. Can you find the entry describing the compiler commands for main.cpp and share that? My guess is that NDEBUG is not defined there.
[
{
"directory": "C:/Users/Steven Upton/Workspace/tearex/build",
"command": "C:\\Users\\STEVEN~1\\scoop\\shims\\clang-cl.exe /nologo -TP -IC:\\VulkanSDK\\1.1.126.0\\Include -I..\\inc /DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -MD /FoCMakeFiles\\tearex.dir\\main.cpp.obj /FdTARGET_COMPILE_PDB -c \"C:\\Users\\Steven Upton\\Workspace\\tearex\\main.cpp\"",
"file": "C:/Users/Steven Upton/Workspace/tearex/main.cpp"
}
]
^ That's what it looks like in the "Release" variant. In "Debug", the /DNDEBUG flag isn't present.
Do you have two separate compile_commands.json files that you switch back and forth between, or does CMake Tools overwrite the one at that location when you change the active variant?
Just the one. When I change the active variant it reconfigures and updates the compile_commands.json file.
Thanks for the info. I think this lies in the realm of cpptools. I'll transfer the issue over and the team can try to help get to the bottom of this. It's possible that the file watcher is not picking up the changes. Or something related to clang-cl. I'm not sure.
Can you enable debug logging (https://code.visualstudio.com/docs/cpp/enable-logging-cpp) and look for what defines is shows being used or any error message related to why it is failing to process the compile_commads.json . Due to bug https://github.com/microsoft/vscode-cpptools/issues/4270 I'm not sure if the compile_commands.json defines are getting used or not.
While getting the logs, I came across the C/C++: Change Configuration Provider... command. Changing it to CMake Tools fixed the issue. I can now switch the variant and the inactive regions update correctly (although, now I'm getting a load of errors when trying the use the standard library).
Thank you for your help!
I spoke too soon. I can't get IntelliSense to work when setting the configuration provider to CMake Tools, I've had to revert back to how I had it. Here's that log that you asked for, no errors that I can see:
initialized
workspace/didChangeConfiguration
IntelliSense Engine = Default.
Autocomplete is enabled.
Enhanced Colorization is enabled.
Error squiggles are enabled if all header dependencies are resolved.
File exclude: **/.git
File exclude: **/.svn
File exclude: **/.hg
File exclude: **/CVS
File exclude: **/.DS_Store
File exclude: **/.vscode
Search exclude: **/node_modules
Search exclude: **/bower_components
Search exclude: **/.vscode
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe'
cpptools/queryCompilerDefaults: 1
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe'
cpptools/activeDocumentChange
cpptools/textEditorSelectionChange
textDocument/didOpen
cpptools/getCodeActions: 2
cpptools/getDocumentSymbols: 3
cpptools/didChangeFolderSettings
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe'
Code browsing service initialized
Attempting to get defaults from compiler found on the machine: 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe'
Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.23.28105/INCLUDE/* will be indexed
Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.23.28105/ATLMFC/INCLUDE/* will be indexed
Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/UM/ will be indexed
Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/UCRT/ will be indexed
Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/SHARED/ will be indexed
Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/WINRT/ will be indexed
Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/CPPWINRT/ will be indexed
Folder: C:/USERS/STEVEN UPTON/WORKSPACE/TEAREX/ will be indexed
textDocument/didOpen
Populate include completion cache.
Discovering files...
cpptools/getDocumentSymbols: 3
cpptools/getDocumentSymbols
sending compilation args for C:\USERS\STEVEN UPTON\WORKSPACE\TEAREX\MAIN.CPP
include: C:\VULKANSDK\1.1.126.0\INCLUDE
include: C:\USERS\STEVEN UPTON\WORKSPACE\TEAREX\INC
include: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.23.28105\INCLUDE
include: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.23.28105\ATLMFC\INCLUDE
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UM
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UCRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\SHARED
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\WINRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\CPPWINRT
define: WIN32
define: _WINDOWS
define: NDEBUG
stdver: ms_c++17
intelliSenseMode: msvc-x64
Processing folder (non-recursive): C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.23.28105/INCLUDE
Processing folder (non-recursive): C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.23.28105/ATLMFC/INCLUDE
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/UM/
Checking for syntax errors: file:///c%3A/Users/Steven%20Upton/Workspace/tearex/main.cpp
Queueing IntelliSense update for files in translation unit of: C:\USERS\STEVEN UPTON\WORKSPACE\TEAREX\MAIN.CPP
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/UCRT/
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/SHARED/
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/WINRT/
Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.18362.0/CPPWINRT/
Processing folder (recursive): C:/USERS/STEVEN UPTON/WORKSPACE/TEAREX/
Discovering files: 5236 file(s) processed
0 file(s) removed from database
Done discovering files.
Parsing open files...
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
Done parsing open files.
cpptools/fileCreated
cpptools/fileCreated
cpptools/fileCreated
Error squiggle count: 0
Update IntelliSense time (sec): 0.799
idle loop: reparsing the active document
Checking for syntax errors: file:///c%3A/Users/Steven%20Upton/Workspace/tearex/main.cpp
Queueing IntelliSense update for files in translation unit of: C:\USERS\STEVEN UPTON\WORKSPACE\TEAREX\MAIN.CPP
Error squiggle count: 0
Update IntelliSense time (sec): 0.259
Database safe to open
cpptools/fileCreated
cpptools/fileDeleted
Database safe to open
Custom configuration provider 'CMake Tools' registered
cpptools/getCodeActions: 4
cpptools/activeDocumentChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/getCodeActions: 5
idle loop: reparsing the active document
Checking for syntax errors: file:///c%3A/Users/Steven%20Upton/Workspace/tearex/main.cpp
Queueing IntelliSense update for files in translation unit of: C:\USERS\STEVEN UPTON\WORKSPACE\TEAREX\MAIN.CPP
Error squiggle count: 0
Update IntelliSense time (sec): 0.258
Your log shows NDEBUG is defined. Are you saying the #ifndef NDEBUG is still shown as active?
Yes, like in the image that I posted. It does include the correct block of code when compiling, it's just the editor that hasn't updated.
It does update if I close and re-open the editor.
We believe we fixed an issue with compile_commands.json updates not being processed which may address this issue. If you install our latest insiders build (change the C_Cpp.updateChannel setting to Insiders), please let us know if the issue persists. Thank you!
Yep works great now, thanks!