Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile_commands.json not working correctly for *.C files since 1.1.0 #6497

Closed
JeanMiK opened this issue Nov 11, 2020 · 8 comments
Closed

compile_commands.json not working correctly for *.C files since 1.1.0 #6497

JeanMiK opened this issue Nov 11, 2020 · 8 comments
Assignees
Labels
bug Feature: Compile Commands fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release
Milestone

Comments

@JeanMiK
Copy link

JeanMiK commented Nov 11, 2020

Type: LanguageService

Since version 1.1.0, it seems like none of my *.C files are recognized anymore in the compile_commands.json, even though they are present.

This is to say, in the 'C/C++ Configuration' output, I get errors of the style

[11/11/2020, 10:56:00 AM] "DbPositionBlockingService.C" not found in "${workspaceFolder}/build/compile_commands.json". 'includePath' from c_cpp_properties.json in folder 'cs.custody' will be used for this file instead.

even though the files are present in the compile_commands.json !

So far, it looks like this is happening only for *.C files, not *.cc files: I have two different workspaces, one in which almost all source files are *.cc, and another one in which almost all the files are *.C, and in both of them, so far, I have seen the error only for the *.C files (meaning that in one of the workspaces, IntelliSense is working quite badly right now).

This is not the same issue than #6311, as it concerns files that exist all the time as real git objects, not only derived / generated items.

Describe the bug

  • OS and Version: Linux RedHat 7.9
  • VS Code Version: 1.51.0
  • C/C++ Extension Version: starting with 1.1.0
  • Other extensions you installed (and if the issue persists after disabling them):
  • Does this issue involve using SSH remote to run the extension on a remote machine?: no
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).

Steps to reproduce

Create a small workspace containing both *.C and *.cc files and a CMakeLists.txt using all of them for different binaries.

Let cmake generate a compile_commands.json

Configure cpptools to use the compile_commands.json generated by cmake

Expected behavior
Opening the different *.C and *.cc files should not yield configuration errors
-->

C/C++: Log Diagnostics
-------- Diagnostics - 11/11/2020, 11:33:01 AM
Version: 1.1.0
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/../cs.ti/deps/rhel7/include",
        "${workspaceFolder}/../cs.ti/deps/rhel7/include/SourcePro2016"
    ],
    "defines": [
        "CRTI_TEMPLATE_INCLUDED=1",
        "_RWCONFIG=m"
    ],
    "compilerPath": "/bin/gcc",
    "cStandard": "c11",
    "cppStandard": "c++11",
    "intelliSenseMode": "gcc-x64",
    "compileCommands": "${workspaceFolder}/build/compile_commands.json",
    "compilerArgs": [],
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "compilerPathIsExplicit": true,
    "browse": {
        "path": [
            "${workspaceFolder}/**",
            "${workspaceFolder}/../cs.ti/deps/rhel7/include",
            "${workspaceFolder}/../cs.ti/deps/rhel7/include/SourcePro2016"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /source/main/cs.custody/Custody/clearstream/src/Services/PositionBlocking/DbPositionBlockingService/DbPositionBlockingService.C ]:
    /source/main/cs.custody/Custody/clearstream/src/Services/PositionBlocking/DbPositionBlockingService/DbPositionBlockingService.C
Translation Unit Configurations:
[ /source/main/cs.custody/Custody/clearstream/src/Services/PositionBlocking/DbPositionBlockingService/DbPositionBlockingService.C ]:
    Process ID: 29159
    Memory Usage: 156 MB
    Compiler Path: /bin/gcc
    Includes:
        /source/main/cs.ti/deps/rhel7/include
        /source/main/cs.ti/deps/rhel7/include/SourcePro2016
        /usr/include/c++/4.8.2
        /usr/include/c++/4.8.2/x86_64-redhat-linux
        /usr/include/c++/4.8.2/backward
        /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include
        /usr/local/include
        /usr/include
        /source/main/cs.custody/Custody/clearstream/src/Services/PositionBlocking/DbPositionBlockingService
        /source/main/cs.custody/Custody_Interfaces/src/BusinessObjects/RequestFlow
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/MailingService
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/OraAPIService
        /source/main/cs.custody/Custody_Interfaces/src/Common/Tools
        /source/main/cs.custody/Custody_Interfaces/src/Services/DatabaseService/GeneratedClasses
        /source/main/cs.custody/Custody_Interfaces/src/Common/LoggingService
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/OAQService
        /source/main/cs.custody/Custody_Interfaces/src/Services/ZlibService
        /source/main/cs.custody/Custody/clearstream/src/BusinessObjects/RequestFlow
        /source/main/cs.custody/Custody/clearstream/src/BusinessObjects/SettlementInstruction
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/CustodyRepository
        /source/main/cs.custody/Custody/clearstream/src/Services/PositionBlocking/Repository/RequestFlowRepository
        /source/main/cs.custody/Custody/clearstream/src/Services/PositionBlocking/Repository/SettlementRequestRepository
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/SyncService
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/DataObjectFramework
        /source/main/cs.custody/Custody_Interfaces/src/BusinessObjects/GeneratedClasses
        /source/main/cs.custody/Custody_Interfaces/src/Common/Exceptions
        /source/main/cs.custody/Custody/clearstream/src/Services/PositionBlocking/Repository/PositionBlockingRepository
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/AccountRepository
        /source/main/cs.custody/Custody_Interfaces/src/Services/Calendar
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/SecurityRepository
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/AccountInsRepository
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/OIDGenService
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/ReceivedMsgRepository
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/CustodianDirectiveRepository
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/CustodianConfirmationRepository
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/TaxGrpRepository
        /source/main/cs.custody/Custody_Interfaces/src/Services/DepositoryService
        /source/main/cs.custody/Custody/clearstream/src/Services/AuthorizeStatus
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/EventTypRepository
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/XMLService/XMLService
        /source/main/cs.custody/Custody_Interfaces/src/BusinessObjects/AccountInstruction
        /source/main/cs.custody/Custody_Interfaces/src/BusinessObjects/CustodianDirective
        /source/main/cs.custody/Custody_Interfaces/src/BusinessObjects/ReferenceData
        /source/main/cs.custody/Custody_Interfaces/src/BusinessObjects/CustEvent
        /source/main/cs.custody/Custody_Interfaces/src/Services/CustodyRepository/CurrencyRepository
        /source/main/cs.custody/Custody_Interfaces/src/TechnicalFramework/Persist
    Defines:
        CRTI_TEMPLATE_INCLUDED=1
        _RWCONFIG=m
    Standard Version: c++11
    IntelliSense Mode: gcc-x64
    Other Flags:
        --g++
        --gnu_version=40805
Total Memory Usage: 156 MB
Browse Paths from compile_commands.json, from workspace folder: /source/main/cs.custody
    /opt/oracle/product/CLT_12201/precomp/public
    /opt/oracle/product/CLT_12201/rdbms/public
    /source/main/cs.custody/Custody/cedel/include
    /source/main/cs.custody/Custody/cedel/interfaces/include
    /source/main/cs.custody/Custody/cedel/interfaces/src
    /source/main/cs.custody/Custody/cedel/lib/include
    /source/main/cs.custody/Custody/cedel/lib/src
    /source/main/cs.custody/Custody/cedel/libcu/include
    /source/main/cs.custody/Custody/cedel/libcu/src
    /source/main/cs.custody/Custody/cedel/purge/common
    /source/main/cs.custody/Custody/cedel/purge/components/acct
    /source/main/cs.custody/Custody/cedel/purge/components/atds
    /source/main/cs.custody/Custody/cedel/purge/components/atrn
    /source/main/cs.custody/Custody/cedel/purge/components/iadc
    /source/main/cs.custody/Custody/cedel/purge/components/include
    /source/main/cs.custody/Custody/cedel/purge/components/ispc
    /source/main/cs.custody/Custody/cedel/purge/components/isph
    /source/main/cs.custody/Custody/cedel/purge/components/issu
    /source/main/cs.custody/Custody/cedel/purge/components/pcss
    /source/main/cs.custody/Custody/cedel/purge/components/psta
    /source/main/cs.custody/Custody/cedel/purge/include
    /source/main/cs.custody/Custody/cedel/purge/purge
    /source/main/cs.custody/Custody/cedel/src
    /source/main/cs.custody/Custody/real/src/include
    /source/main/cs.custody/Custody/real/src/utilities
    /source/main/cs.custody/Custody_Interfaces/include
    /source/main/cs.custody/Custody_Interfaces/src/Services/Hashlib
    /source/main/cs.custody/Custody_Interfaces/src/Services/MirrorService
    /source/main/cs.custody/Custody_Interfaces/src/Services/MirrorService/grpc
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService/alert
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService/caevent
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService/database
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService/taxrequest
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService/test
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService/texasdbsvc
    /source/main/cs.custody/Custody_Interfaces/src/Services/TexasService/types
    /source/main/cs.custody/build/Custody/cedel/interfaces/src
    /source/main/cs.custody/build/Custody/cedel/lib/src
    /source/main/cs.custody/build/Custody/cedel/libcu/src
    /source/main/cs.custody/build/Custody/cedel/purge/common
    /source/main/cs.custody/build/Custody/cedel/purge/components/acct
    /source/main/cs.custody/build/Custody/cedel/purge/components/atds
    /source/main/cs.custody/build/Custody/cedel/purge/components/atrn
    /source/main/cs.custody/build/Custody/cedel/purge/components/iadc
    /source/main/cs.custody/build/Custody/cedel/purge/components/ispc
    /source/main/cs.custody/build/Custody/cedel/purge/components/isph
    /source/main/cs.custody/build/Custody/cedel/purge/components/issu
    /source/main/cs.custody/build/Custody/cedel/purge/components/pcss
    /source/main/cs.custody/build/Custody/cedel/purge/components/psta
    /source/main/cs.custody/build/Custody/cedel/purge/purge
    /source/main/cs.custody/build/Custody/cedel/src
    /source/main/cs.custody/build/Custody/real/src/utilities
    /source/main/cs.custody/build/Custody_Interfaces/src/Services/Hashlib
    /source/main/cs.custody/build/Custody_Interfaces/src/Services/MirrorService/grpc
    /source/main/cs.custody/build/Custody_Interfaces/src/Services/TexasService
    /source/main/cs.custody/build/Custody_Interfaces/src/Services/TexasService/test
    /source/main/cs.ti/deps/rhel7/include/SourcePro2016
    /source/main/cs.ti/deps/rhel7/include/grpc-1.18.0
    /source/main/cs.ti/deps/rhel7/include/protobuf_3.6.1

------- Workspace parsing diagnostics -------
Number of folders and files enumerated: 34291
Number of files discovered (not excluded): 30126

Screenshots

Additional context

@Colengms Colengms self-assigned this Nov 11, 2020
@Colengms
Copy link
Contributor

Hi @JeanMiK . Thanks for reporting this. There appears to be an issue with how the extension is handling ".C" files, which are (internally) mapped to C++ using the files.association setting.

@Colengms Colengms added this to the 1.2.0 milestone Nov 11, 2020
@Colengms Colengms added the regression A bug that didn't exist in a previous release label Nov 11, 2020
@Colengms Colengms changed the title compile_commands.jason not working correctly for *.C files since 1.1.0 compile_commands.json not working correctly for *.C files since 1.1.0 Nov 11, 2020
@Colengms Colengms added the fixed Check the Milestone for the release in which the fix is or will be available. label Nov 11, 2020
@sean-mcmanus sean-mcmanus pinned this issue Nov 12, 2020
@sean-mcmanus sean-mcmanus unpinned this issue Nov 16, 2020
@JeanMiK
Copy link
Author

JeanMiK commented Jan 19, 2021

I now got 1.2.0-insiders installed, and this is still not working, neither for my real workspaces, nor for a small dummy test workspace with just 3 files:

I have the following compile_commands.json:

[
{
  "directory": "/home/ec2-user/c++_tests",
  "command": "/bin/c++   -I/home/ec2-user/c++_tests    -std=c++11 -pedantic-errors -g -fdiagnostics-show-option -Wall -Wno-long-long -Werror -o CMakeFiles/test_unordered.dir/test_unordered.cc.o -c /home/ec2-user/c++_tests/test_unordered.cc",
  "file": "/home/ec2-user/c++_tests/test_unordered.cc"
},
{
  "directory": "/home/ec2-user/c++_tests",
  "command": "/bin/c++   -I/home/ec2-user/c++_tests    -std=c++11 -pedantic-errors -g -fdiagnostics-show-option -Wall -Wno-long-long -Werror -o CMakeFiles/test_uintConversion.dir/test_uintConversion.C.o -c /home/ec2-user/c++_tests/test_uintConversion.C",
  "file": "/home/ec2-user/c++_tests/test_uintConversion.C"
},
{
  "directory": "/home/ec2-user/c++_tests",
  "command": "/bin/c++   -I/home/ec2-user/c++_tests    -std=c++11 -pedantic-errors -g -fdiagnostics-show-option -Wall -Wno-long-long -Werror -o CMakeFiles/test_snprintf.dir/test_snprintf.C.o -c /home/ec2-user/c++_tests/test_snprintf.C",
  "file": "/home/ec2-user/c++_tests/test_snprintf.C"
}
]

And as with the 1.1 releases, I still get configuration errors when opening any of the *.C files

[1/19/2021, 6:30:32 PM] "test_snprintf.C" not found in "compile_commands.json". 'includePath' from c_cpp_properties.json in folder 'c++_tests' will be used for this file instead.
[1/19/2021, 6:30:57 PM] "test_uintConversion.C" not found in "compile_commands.json". 'includePath' from c_cpp_properties.json in folder 'c++_tests' will be used for this file instead.

while test_unordered.cc works without a problem

@Colengms
Copy link
Contributor

Hi @JeanMiK . Thanks for letting us know. It looks like this was fixed on Windows, but there was an issue blocking that fix on Linux/Mac. I have another fix in progress that should make it into 1.2.0-insiders2.

@sean-mcmanus
Copy link
Contributor

@bobbrow bobbrow added fixed Check the Milestone for the release in which the fix is or will be available. and removed fixed Check the Milestone for the release in which the fix is or will be available. labels Jan 26, 2021
@Colengms Colengms closed this as completed Feb 3, 2021
@fcharron
Copy link

fcharron commented Feb 10, 2021

I'm now on 1.2.0 and am experiencing this problem still, on WSL 2.

OS: Windows 10 - WSL mode (Ubuntu 18.04)
Standard Version requested: gnu++11
Standard Version (detected): c89
Compiler Path: /ross/zynq_bonza/usr/bin/arm-linux-g++
IntelliSense Mode: linux-gcc-arm
Other Flags: --gcc --gnu_version=40703
compile_commands.json entry:

directory: /home/fcharron/code/ipworkspace/rtr-projects/ultrix-5ru/package/mv_control/dist/util
file: /home/fcharron/code/ipworkspace/rtr-projects/ultrix-5ru/package/mv_control/util/dynbuf.c
command: /ross/zynq_bonza/usr/bin/arm-linux-g++  -I/home/fcharron/code/ipworkspace/rtr-projects/ultrix-5ru/package/mv_control/util/. -I/home/fcharron/code/ipworkspace/rtr-projects/ultrix-5ru/package/mv_control/util/ogp -I/home/fcharron/code/ipworkspace/rtr-projects/ultrix-5ru/package/mv_control/cJSON/. -std=gnu++11 -Os -DNDEBUG -std=gnu++11 -o CMakeFiles/mv_util.dir/dynbuf.c.o -c /home/fcharron/code/ipworkspace/rtr-projects/ultrix-5ru/package/mv_control/util/dynbuf.c

@fcharron
Copy link

As I read the original issue description a bit more attentively, I think the OP's problem was the opposite of mine: I want .c files to be treated as C++, as described in the compile_commands.json, and they're not. I tried setting the user files.associations setting as so:

"files.associations":{
        "**/*.c": "cpp",
        "**/*.h": "cpp"
    },

And the files still get treated as C.

Let me know if I should open a separate issue for this.

@Colengms
Copy link
Contributor

Colengms commented Feb 10, 2021

Hi @fcharron . I believe those should be filename patterns. I'm not able to repro an issue when using "*.c" and "*.h".

@fcharron
Copy link

Oh, that's interesting... I always thought that file associations could be set on a per-file basis too.

Indeed, using

"files.associations":{
        "*.c": "cpp",
        "*.h": "cpp"
    },

works fine. I think what threw me off was that when editing that specific file, I must have set the language mode directly to C++, from the bottom-right indicator, and I still was seeing squiggles on reinterpret_cast, for instance.

Thanks for the clarification @Colengms !

@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Compile Commands fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release
Projects
None yet
Development

No branches or pull requests

5 participants