Vscode-cpptools: Add support for -iframework in compile_commands.json (Intellisense stopped working for Qt libraries on Mac only)

Created on 6 Jan 2020  路  26Comments  路  Source: microsoft/vscode-cpptools

Type: LanguageService

Describe the bug

  • OS and Version: Mac 10.15 Catalina
  • VS Code Version: 1.41
  • C/C++ Extension Version: All recent versions (tried multiple)
  • Other extensions you installed (and if the issue persists after disabling them): Cmake Tools - persists on disabling
  • A clear and concise description of what the bug is.

It seems cpptools intellisense engine has stopped working for Qt types (at least for me). It works fine with the same config on Linux. The problem seems concentrated around finding Qt includes...

To Reproduce

Install Qt open source library under Mac - placed in ~/Qt. Configure CMakeLists.txt to correctly include required libraries and headers (see simple GUI project here). I added the Qt include directories with include_directories (Qt5Core_INCLUDE_DIRS, Qt5Widgets_INCLUDE_DIRS, etc). Point c_cpp_properties to the correct clang compiler and compile_commands.json file (make sure generating compile_commands to specified location). Here is mine:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compileCommands": "${workspaceFolder}/build/compile_commands.json",
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++14",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

Basically any header include which has a Qt type somewhere gets a red squiggle, and all Qt types receive no autocomplete suggestions. When I first installed vscode and the extension on Mac, it was working to complete Qt types fine with the above config. Then something happened and it stopped working - unfortunately I don't know what exactly as this is a new iMac and I have been installing software and updates continually. I do know that the OS was updated to Catalina, but it seems it was working after that update and restart.

Things I have tried

Adding Qt include directories under includePath - both individually and adding all of them as a top level glob ** (I am confused on the necessity of includePath when compile_commands is included in general - is it used in this case?)

Completely reinstalling vscode (deleting all config files in global .vscode) and starting from scratch with the extension.

Installing different versions of cpptools with auto update extensions turned off.

Moving compile commands around to different locations and updating the location in c_cpp_properties.

Using clang compiler included with XCode (turns out it is same exact one as installed by homebrew anyways)

Setting intellisense include backup behavior to use tags - this causes the red squiggles to change to blue, and most Qt types then have auto-completion available however the context for the completion is not correct

Expected behavior

I would expect intellisense actions to work correctly with Qt. The project compiles with cmake_tools and clang 11 with no problems.

I will also note that as a backup I have cquery installed (brew install cquery), and if I disable the language server in settings, enable the cquery extension and reload vscode, cquery has no trouble finding any of the types, includes, or type completions based on my compile_commands.json. This tells me either I have something configured incorrectly for cpptools, or there is a bug somewhere.

Thanks

Compile Commands Configuration Language Service bug fixed (release pending)

All 26 comments

Can you try doing a C/C++: Reset IntelliSense Database command? Also, can you run C/C++: Log Diagnostics with the squiggled file active and see if you the includePaths shown are correct?

If compile_commands.json is being used, you shouldn't need to make changes to includePath unless for source files that are missing from compile_commands.json.

Can you try doing a C/C++: Reset IntelliSense Database command? Also, can you run C/C++: Log Diagnostics with the squiggled file active and see if you the includePaths shown are correct?

I have tried to do the Reset IntelliSense Database command in every test case I mentioned above - I will try the logging command this this evening and let you know the results - thanks for the quick response!

So - running the log diagnostics it definitely shows that the correct Qt header directories are included.. but still red squiggles under all Qt header files.. here is the log diagnostics output

Version: 0.26.3-insiders2
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "${workspaceFolder}/include/**"
    ],
    "compileCommands": "${workspaceFolder}/build/compile_commands.json",
    "compilerPath": "/usr/bin/clang",
    "defines": [],
    "macFrameworkPath": [
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
    ],
    "cStandard": "c11",
    "cppStandard": "c++14",
    "intelliSenseMode": "clang-x64",
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}/include/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_tag.cpp ]:
    /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_tag.cpp
Translation Unit Configurations:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_tag.cpp ]:
    Process ID: 4073
    Memory Usage: 141 MB
    Compiler Path: /usr/bin/clang
    Includes:
        /Users/dprandle/Documents/Code/Uber_Mail/build/Debug
        /Users/dprandle/Documents/Code/Uber_Mail
        /Users/dprandle/Documents/Code/Uber_Mail/include
        /Users/dprandle/Documents/Code/Uber_Mail/build/Debug/include
        /usr/local/Cellar/[email protected]/1.1.1d/include
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/mkspecs/macx-clang
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/Headers
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtNetwork.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtPrintSupport.framework/Versions/5/Headers
        /usr/local/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
    Frameworks:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Defines:
        DEBUG_VERSION
        QT_CORE_LIB
        QT_GUI_LIB
        QT_NETWORK_LIB
        QT_PRINTSUPPORT_LIB
        QT_WIDGETS_LIB
    Standard Version: c++14
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=110000
Total Memory Usage: 141 MB

And here are my global cpp tools settings:

    // C_Cpp Tools
    "C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
    "C_Cpp.autocomplete": "Default",
    "C_Cpp.default.compilerPath": "/usr/bin/clang",
    "C_Cpp.experimentalFeatures": "Enabled",
    "C_Cpp.default.cppStandard": "c++14",
    "C_Cpp.intelliSenseEngineFallback": "Disabled",
    "C_Cpp.intelliSenseEngine": "Default",
    "C_Cpp.formatting": "Disabled",

And here are some screenshots of the error message in vscode, and proof that the file it says it can't find is indeed in the folder referenced in the include directory shown in log diagnostics

Screen Shot 2020-01-06 at 11 24 40 PM

Screen Shot 2020-01-07 at 12 08 59 AM

Could this be a weird permissions thing? I normally work in linux and am fairly new to MacOS

Thanks!

Just a quick update - as I am new to Mac I didn't realize "frameworks" were a thing... Qt ships its libs on Mac as frameworks so this definitely has something to do with it..

I changed my config file so that it was

            "macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks",
                "/Users/dprandle/Qt/5.12.6/clang_64/lib"
            ],

Reset the database, waited for all files to be parsed again, then reloaded vscode, and unfortunately the problem persists.

Hmm, looks like we had the same report back in March 2019 at https://github.com/microsoft/vscode-cpptools/issues/3323, but we never had time investigate it.

Well let me know if I can further help out - would be great to get this working but I know you all are very busy - thanks

How are the Qt dependencies being #includeed? I remember working on this a long time ago, but I believe that the Qt examples do stuff like:

#include <QtWidgets>

whereas our compiler expects it to use Framework syntax:

#include <QtWidgets/QtWidgets>

because QtWidgets exists under the QtWidgets.framework folder.

My macFrameworkPath is ~/qt/5.9.1/clang_64/lib and IntelliSense works for me when I do it the second way.

Ill try this again tonight - Im a bit skeptical that it will work because it wasnt finding QtCore/QVariant which should appear under the framework.. in any case - since it compiles and the headers from the framework directories are part of includePath - shouldnt work directly? If I was any good at javascript I would investigate further myself :/

@dprandle The code that handles this is in our closed source language server (not the open source TypeScript).

So - it doesn't matter how I include the files - whether QString or QtCore/QString - IntelliSense is not working.. oddly enough it does at least see the headers and autocompletes the header files when I include the Qt framework path.. but after it squiggles them red and IntelliSense for the type doesn't work..

Again - let me know if you would like me to check anything else with it - for me this issue is reproducible on any new simple Qt project I create on Mac

Thanks

Can you run C/C++: Log Diagnostics one more time (with the macFrameworkPath set) and share that? I couldn't understand how you got the includes that you did based on the configuration that was shown. Something didn't look right.

I take that back. I missed that you're using compile_commands.json. Please share the entry for the file giving you squiggles instead (dialog_create_tag.cpp).

So, if I follow include jumps (using follow symbol under cursor), it continues all the way to the Qt files.. In this case I ran Log Diagnostics in qfile.h... What's interesting here to me is that, despite having the Qt framework added in Mac frameworks section of the configuration, it doesn't show up under frameworks in Log Diagnostics... should it?

-------- Diagnostics - 1/8/2020, 11:36:50 PM
Version: 0.26.3-insiders3
Current Configuration:
{
    "name": "Mac",
    "configurationProvider": "",
    "macFrameworkPath": [
        "/Users/dprandle/Qt/5.12.6/clang_64/lib"
    ],
    "compileCommands": "${workspaceFolder}/build/compile_commands.json",
    "cppStandard": "c++14",
    "cStandard": "c11",
    "intelliSenseMode": "clang-x64",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "compilerPath": "/usr/bin/clang",
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/approval_proxy_filter.cpp ]:
    /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/Headers/qfile.h
Translation Unit Configurations:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/approval_proxy_filter.cpp ]:
    Process ID: 1775
    Memory Usage: 107 MB
    Compiler Path: /usr/bin/clang
    Includes:
        /Users/dprandle/Documents/Code/Uber_Mail/build/Debug
        /Users/dprandle/Documents/Code/Uber_Mail
        /Users/dprandle/Documents/Code/Uber_Mail/include
        /Users/dprandle/Documents/Code/Uber_Mail/build/Debug/include
        /usr/local/Cellar/[email protected]/1.1.1d/include
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/mkspecs/macx-clang
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/Headers
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtNetwork.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtPrintSupport.framework/Versions/5/Headers
        /usr/local/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/Headers
    Frameworks:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Defines:
        DEBUG_VERSION
        QT_CORE_LIB
        QT_GUI_LIB
        QT_NETWORK_LIB
        QT_PRINTSUPPORT_LIB
        QT_WIDGETS_LIB
    Standard Version: c++14
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=110000
Total Memory Usage: 107 MB

Thanks

Another sort of strange thing - is if I change to get the configuration from cmake tools extension.. The framework appears but cpptools apparently thinks cmake tools is using gcc... IntelliSense
still does not work, but my log diagnostics looks like this:

-------- Diagnostics - 1/8/2020, 11:48:14 PM
Version: 0.26.3-insiders3
Current Configuration:
{
    "name": "Mac",
    "configurationProvider": "ms-vscode.cmake-tools",
    "macFrameworkPath": [
        "/Users/dprandle/Qt/5.12.6/clang_64/lib",
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
    ],
    "compilerArgs": [],
    "cppStandard": "c++14",
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_view_payrolls.cpp ]:
    /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_view_payrolls.cpp
Translation Unit Configurations:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_view_payrolls.cpp ]:
    Process ID: 2664
    Memory Usage: 6 MB
    Compiler Path: /usr/local/bin/gcc-8
    Includes:
        /usr/local/Cellar/gcc@8/8.3.0_2/include/c++/8.3.0
        /usr/local/Cellar/gcc@8/8.3.0_2/include/c++/8.3.0/x86_64-apple-darwin19
        /usr/local/Cellar/gcc@8/8.3.0_2/include/c++/8.3.0/backward
        /usr/local/Cellar/gcc@8/8.3.0_2/lib/gcc/8/gcc/x86_64-apple-darwin19/8.3.0/include
        /usr/local/Cellar/gcc@8/8.3.0_2/lib/gcc/8/gcc/x86_64-apple-darwin19/8.3.0/include-fixed
        /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
        /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks
    Frameworks:
        /Users/dprandle/Qt/5.12.6/clang_64/lib
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Standard Version: c++14
    IntelliSense Mode: gcc-x64
    Other Flags:
        --g++
        --gnu_version=80300
Total Memory Usage: 6 MB

In order to get the same results as the previous log I posted, I have to select the clang kit in cmake again. Once I do that I get the same results where the Qt path is not in Frameworks...

Just verified this morning that all works on Linux with Qt - in fact the only thing needed on Linux is the path to compile_commands.json and it works perfectly... I think it has to do something with the Mac frameworks - Qt is even in the same ~/Qt/5.12.6/gcc_64 style folder on my ubuntu install

  1. When you use compile_commands.json, we don't look at the value of macFrameworkPath because we expect the non-system frameworks to be listed in the command. It's possible it could be specified in some format that we don't recognize.
  2. RE: gcc. On macOS we will choose gcc if we discover it and no other compiler is set for compilerPath. Our reasoning is that if you installed it you probably wanted to use it. We allowed compilerPath to override the compiler set in compile_commands.json as a workaround for some build systems (e.g. someone wraps their build with a script).

I strongly suspect that the issue is with the compile_commands.json file. Can you share the entry for dialog_create_tag.cpp so we can see what it looks like? It will be in this format or similar:

{
  "directory": "/Users/...",
  "command": "clang ...",
  "file": ".../dialog_create_tag.cpp"
}

Here is the entry for dialog_create_tag

{
  "directory": "/Users/dprandle/Documents/Code/Uber_Mail/build/Debug",
  "command": "/usr/bin/clang++  -DDEBUG_VERSION -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -I/Users/dprandle/Documents/Code/Uber_Mail/build/Debug -I/Users/dprandle/Documents/Code/Uber_Mail -I/Users/dprandle/Documents/Code/Uber_Mail/include -I/include -I/usr/local/include -I/usr/local/opt/[email protected]/include -iframework /Users/dprandle/Qt/5.12.6/clang_64/lib -isystem /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework/Headers -isystem /Users/dprandle/Qt/5.12.6/clang_64/./mkspecs/macx-clang -isystem /Users/dprandle/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Headers -isystem /Users/dprandle/Qt/5.12.6/clang_64/lib/QtGui.framework/Headers -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/Headers -isystem /Users/dprandle/Qt/5.12.6/clang_64/lib/QtNetwork.framework/Headers -isystem /Users/dprandle/Qt/5.12.6/clang_64/lib/QtPrintSupport.framework/Headers  -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk   -fPIC -std=gnu++14 -o CMakeFiles/UberMail-v3.0.0-alpha.5.dir/src/dialog_create_tag.cpp.o -c /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_tag.cpp",
  "file": "/Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_tag.cpp"
}

Thanks

It looks like our compile commands code doesn't handle "-iframework", just "-framework" and "-F", i.e. the fix would be to add support for that.

As a workaround, you may want to try removing the compileCommands and setting your configurationProvider to be "ms-vscode.cmake-tools" (with the CMake Tools extension installed). We expect the config experience with CMake Tools to be better than with just compile_commands.json.

Couple things...
First - unfortunately using cmake tools as the configuration provider still doesn't work.. And I copied the compile commands everywhere in my project just to be sure... here is what running log diagnostics on one of my files looks like

-------- Diagnostics - 1/10/2020, 3:47:56 PM
Version: 0.26.3-insiders3
Current Configuration:
{
    "name": "Mac",
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "limitSymbolsToIncludedHeaders": false
    },
    "compilerArgs": []
}
Translation Unit Mappings:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_payroll.cpp ]:
    /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_payroll.cpp
Translation Unit Configurations:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_payroll.cpp ]:
    Process ID: 17467
    Memory Usage: 166 MB
    Compiler Path: /usr/bin/clang++
    Includes:
        /Users/dprandle/Documents/Code/Uber_Mail/build/Debug
        /Users/dprandle/Documents/Code/Uber_Mail
        /Users/dprandle/Documents/Code/Uber_Mail/include
        /usr/local/include
        /usr/local/Cellar/[email protected]/1.1.1d/include
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/mkspecs/macx-clang
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtWidgets.framework
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtGui.framework
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/Headers
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtNetwork.framework
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtNetwork.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtPrintSupport.framework
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtPrintSupport.framework/Versions/5/Headers
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
    Frameworks:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Defines:
        DEBUG_VERSION
        QT_CORE_LIB
        QT_GUI_LIB
        QT_NETWORK_LIB
        QT_PRINTSUPPORT_LIB
        QT_WIDGETS_LIB
    Standard Version: c++14
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=110000
Total Memory Usage: 166 MB

Second - looks like the extension doesn't pull in the selected kit correctly if cmake finds more than just clang on Mac... This is what happens.. I select the clang kit, compile, and now cpptools gets the configuration correctly.. However, reloading VSCode causes cpptools to think I'm using gcc... even if I reconfigure with cmake and compile - it doesn't get the selected kit correct again until I deliberately select the clang kit with cmake tools and compile again - and I know cmake is compiling with clang not gcc as I can see it on my build output

Thanks

For the 1st issue, it looks like we would obtain the frameworks from querying the compilerPath/compilerArgs from CMake Tools and they don't send us that info directly, but the compiler may not be labeling the -iframework with "(framework directory)" like it does with the MacOSX.sdk framework (but it looks like gcc might be outputing the framework with that text, unlike clang, because we correctly recognize it as a framework in that case, from your logs). So it looks like another bug.

For the 2nd issue, it sounds like setting the CMake.configureOnOpen setting would fix that.

@bobbrow Can you think of any workaround? (Maybe switch to using -framework or -F someone in the compile commands) Any idea why we haven't gotten other reports like this yet?

UPDATE: Looks like we handle -iframework as an arg correctly (it does output "framework directory"), maybe CMake Tools isn't passing that as a compilerArg when the clang kit is used for some reason.

Also, fixing https://github.com/microsoft/vscode-cpptools/issues/1755 would fix this as well, since we correctly respond to "-iframework" when it's a compilerArg -- so a potential workaround is to set your compilerPath to something like "/usr/bin/clang++ -iframework /Users/dprandle/Qt/5.12.6/clang_64/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fPIC". If that doesn't work, there could be additional issues.

Success! The only compiler arg that's necessary for IntelliSense to work correctly (I tried including/not including all shown above) to include is the -iframework pointing to the Qt lib. I'm guessing this would be true of any other 3rd part framework one would want to use in VSCode. As you mentioned earlier - I think IntelliSense is not recognizing the -iframework arg in compile_commands.json, but when you expressly list it as an arg it correctly handles it. Here is my log diagnostics with IntelliSense working correctly

-------- Diagnostics - 1/11/2020, 3:07:10 PM
Version: 0.26.3-insiders3
Current Configuration:
{
    "name": "Mac",
    "compilerPath": "/usr/bin/clang++",
    "compilerArgs": [
        "-iframework",
        "/Users/dprandle/Qt/5.12.6/clang_64/lib"
    ],
    "compileCommands": "${workspaceFolder}/build/compile_commands.json",
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_payroll.cpp ]:
    /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_payroll.cpp
Translation Unit Configurations:
[ /Users/dprandle/Documents/Code/Uber_Mail/src/dialog_create_payroll.cpp ]:
    Process ID: 1662
    Memory Usage: 207 MB
    Compiler Path: /usr/bin/clang++
    Includes:
        /Users/dprandle/Documents/Code/Uber_Mail/build/Debug
        /Users/dprandle/Documents/Code/Uber_Mail
        /Users/dprandle/Documents/Code/Uber_Mail/include
        /Users/dprandle/Documents/Code/Uber_Mail/build/Debug/include
        /usr/local/Cellar/[email protected]/1.1.1d/include
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtCore.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/mkspecs/macx-clang
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtWidgets.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtGui.framework/Versions/5/Headers
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtNetwork.framework/Versions/5/Headers
        /Users/dprandle/Qt/5.12.6/clang_64/lib/QtPrintSupport.framework/Versions/5/Headers
        /usr/local/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
    Frameworks:
        /Users/dprandle/Qt/5.12.6/clang_64/lib
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Defines:
        DEBUG_VERSION
        QT_CORE_LIB
        QT_GUI_LIB
        QT_NETWORK_LIB
        QT_PRINTSUPPORT_LIB
        QT_WIDGETS_LIB
    Standard Version: c++17
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=110000
Total Memory Usage: 207 MB

You can see here that the Qt lib is included under frameworks where it previously was not.

Thanks for the help!

Thank you for posting such a kind review of the extension. We really appreciate it.

Our latest Insiders released added support for -iframework in compile_commands.json: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders

Thank you! removed the above work around and seems to be working great!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisckc picture chrisckc  路  3Comments

jheinzel picture jheinzel  路  3Comments

wdc596933938 picture wdc596933938  路  3Comments

SkyRiderMike picture SkyRiderMike  路  3Comments

ecbrodie picture ecbrodie  路  3Comments