microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.5k stars 1.55k forks source link

C_Cpp.errorSquiggles on constant macro M_LN2 etc in <math.h> #12767

Open yuw444 opened 1 day ago

yuw444 commented 1 day ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary:

Error squiggles on the constant macro from , but Go to Definition could locate the constant from the includedPath

Steps to reproduce:

  1. error squiggles on the constant
  2. hover on the constant, click the view problem
  3. error:[{ "resource": "/scratch/g/pauer/Yu/bcftools-1.20/plugins/mocha.c", "owner": "C/C++: IntelliSense", "code": "20", "severity": 8, "message": "identifier \"M_LN2\" is undefined", "source": "C/C++", "startLineNumber": 42, "startColumn": 104, "endLineNumber": 42, "endColumn": 109 }]
  4. click Go to Definition, definitions showed up from 3 possible paths, which are in includedPath

Expected behavior: no error squiggles, but I don't like to disable the error.squiggles feature when true error shows

Configuration and Logs

{
  "configurations": [
    {
      "name": "linux-gcc-x64",
      "includePath": [
        "${workspaceFolder}/**",
        "/home/yu89975/local/include",
        "/home/yu89975/local/include/gsl",
        "/usr/include"

      ],
      "compilerPath": "/home/yu89975/local/bin/gcc",
      "cStandard": "c11",
      "cppStandard": "c++11",
      "intelliSenseMode": "linux-gcc-x64",
      "compilerArgs": [
        ""
      ]
    }
  ],
  "version": 4
}

-------- Diagnostics - 9/25/2024, 10:09:17 AM
Version: 1.22.4
Current Configuration:
{
    "name": "linux-gcc-x64",
    "includePath": [
        "/scratch/g/pauer/Yu/bcftools-1.20/**",
        "/home/yu89975/local/include",
        "/home/yu89975/local/include/gsl",
        "/usr/include"
    ],
    "compilerPath": "/home/yu89975/local/bin/gcc",
    "cStandard": "c11",
    "cppStandard": "c++11",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerArgs": [
        ""
    ],
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/home/yu89975/local/bin/gcc",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/scratch/g/pauer/Yu/bcftools-1.20/**",
            "/home/yu89975/local/include",
            "/home/yu89975/local/include/gsl",
            "/usr/include",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.default.compilerPath": "/home/yu89975/local/bin/gcc"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.rmd": "markdown"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true,
        "**/*.crswap": true
    },
    "filesAutoSaveAfterDelay": true,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.22.4.0
Translation Unit Mappings:
[ /scratch/g/pauer/Yu/bcftools-1.20/plugins/mocha.c - source TU]:
Translation Unit Configurations:
[ /scratch/g/pauer/Yu/bcftools-1.20/plugins/mocha.c ]
    Process ID: 3015901
    Memory Usage: 27 MB
    Compiler Path: /home/yu89975/local/bin/gcc
    Includes:
        /home/yu89975/local/include/gsl
        /scratch/g/pauer/Yu/bcftools-1.20
        /scratch/g/pauer/Yu/bcftools-1.20/doc
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/cram
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/htscodecs
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests/dat
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests/dat/arith
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests/dat/fqzcomp
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests/dat/r4x16
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests/dat/r4x8
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests/names
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htscodecs/tests/names/tok3
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/htslib
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/m4
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/os
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/samples
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/annot-tsv
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/base_mods
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/bcf-sr
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/faidx
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/fastq
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/fuzz
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/longrefs
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/maintainer
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/mpileup
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/sam_filter
        /scratch/g/pauer/Yu/bcftools-1.20/htslib-1.20/test/tabix
        /scratch/g/pauer/Yu/bcftools-1.20/m4
        /scratch/g/pauer/Yu/bcftools-1.20/misc
        /scratch/g/pauer/Yu/bcftools-1.20/mocha_test
        /scratch/g/pauer/Yu/bcftools-1.20/mpileup_bench
        /scratch/g/pauer/Yu/bcftools-1.20/plugins
        /scratch/g/pauer/Yu/bcftools-1.20/test
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/EDUMMY0001
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/EDUMMY0002
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/EDUMMY0003
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/EMN908947
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENSG00000173376
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENSMUST00000121418
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENSMUST00000133836
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000000000
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000218032
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000227471
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000230048
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000256452
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000263103-INS
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000269081
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000271583
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000285021
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000294661
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000295641
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000301246
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000303039
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000318249
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000318249.2
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000329454
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000341065
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000357367
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000360372
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000368801
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000368801.2
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000373833
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000375992
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000378322
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000379416
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000381157
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000382647
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000390520
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000400151
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000409523
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000410009
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000413103
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000420190
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000420670
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000422159
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000423372
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000436063
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000448695
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000479739
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000518414
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000518414-ENST00000521270
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000519442
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000520795
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000520868
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000528237
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000536784
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000542803
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000543077
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000545279
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000557788
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000571540
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000573314
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000580206
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000593942
        /scratch/g/pauer/Yu/bcftools-1.20/test/csq/ENST00000624631
        /scratch/g/pauer/Yu/bcftools-1.20/test/mpileup
        /scratch/g/pauer/Yu/bcftools-1.20/test/trio-dnm
    System Includes:
        /home/yu89975/local/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include
        /usr/local/include
        /home/yu89975/local/include
        /home/yu89975/local/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include-fixed
        /usr/include
    Standard Version: c11
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=90300
Total Memory Usage: 27 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 14533
Number of files parsed: 500

Other Extensions

No response

Additional context

No response

Colengms commented 11 hours ago

Hi @yuw444 I'm not easily able to repro this issue. However, you appear to be using a specific version of gcc installed under your home directory, so that may explain the difference.

If there are preprocessor conditionals around the definition, it's possible that IntelliSense hasn't been provided (or generated) those definitions. 'Go To Definition' may still work, as that feature is based on a lexical/syntactic parse of source/header files (which get stored into a database), while IntelliSense squiggles are a result of a semantic parse (front end compilation) of the source and headers it includes.

Does the file that is repro'ing the issue compile directly via command line? If so, are those same arguments also present in your configuration? IntelliSense internally uses a C++ front-end to compile source code, so would require the same information required to compile the file via command line.