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

Add support for /cygdrive paths returned by some versions of Cygwin #10112

Closed
jantajov opened this issue Nov 4, 2022 · 8 comments
Closed

Add support for /cygdrive paths returned by some versions of Cygwin #10112

jantajov opened this issue Nov 4, 2022 · 8 comments
Assignees
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@jantajov
Copy link

jantajov commented Nov 4, 2022

Hi,

I am facing error: "Cannot open source file stddef.h" (dependency of stdlib.h)" when editing c files.

image

Archive with CygWin installation: https://1drv.ms/u/s!AhQbYFkanIg5h5RrrKO2FXw8tPj23Q?e=1igDaK

Config:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": ["${workspaceFolder}/**"],
            "defines": ["_DEBUG", "UNICODE", "_UNICODE"],
            "compilerPath": "C:\\Program Files\\CygWin64\\bin\\gcc.exe",
            "cStandard": "c99",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

Weirdly enough Intelli-Sense seems to work just fine.
image

image

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Nov 4, 2022

You may not have the required headers/libraries installed. Are you able to compile with C:\Program Files\CygWin64\bin\gcc.exe ?

What output do you get when you run the C/C++: Log Diagnostics command from the Command Palette? The includePath to stddef.h is most likely missing. You might try searching for that file.

Also, you may try changing your intelliSenseMode to "windows-gcc-x64" to see if that helps.

@sean-mcmanus sean-mcmanus self-assigned this Nov 4, 2022
@sean-mcmanus sean-mcmanus added Language Service more info needed The issue report is not actionable in its current state Feature: Configuration An issue related to configuring the extension or IntelliSense labels Nov 4, 2022
@jantajov
Copy link
Author

jantajov commented Nov 4, 2022

Hi Sean,

You may not have the required headers/libraries installed. Are you able to compile with C:\Program Files\CygWin64\bin\gcc.exe ?

If I press Ctrl + Shift + B it builds just fine. Giving me folowing output:

 *  Executing task: C/C++: gcc.exe build active file 

Starting build...
"C:\Program Files\CygWin64\bin\gcc.exe" -fdiagnostics-color=always -g C:\Users\tajovsky\Desktop\c-proj\main.c -o C:\Users\tajovsky\Desktop\c-proj\main.exe

Build finished successfully.
 *  Terminal will be reused by tasks, press any key to close it. 

here is output from Log Diagnostics. LGTM...

-------- Diagnostics - 4. 11. 2022 23:57:47
Version: 1.12.4
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "compilerPath": "C:\\Program Files\\CygWin64\\bin\\gcc.exe",
    "cStandard": "c99",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-gcc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ C:\Users\tajovsky\Desktop\c-proj\main.c ]:
    C:\Users\tajovsky\Desktop\c-proj\main.c
Translation Unit Configurations:
[ C:\Users\tajovsky\Desktop\c-proj\main.c ]:
    Process ID: 7776
    Memory Usage: 17 MB
    Compiler Path: c:\program files\cygwin64\bin\gcc.exe
    Includes:
        C:\PROGRAM FILES\CYGWIN64\USR\INCLUDE
        C:\PROGRAM FILES\CYGWIN64\USR\INCLUDE\W32API
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c99
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=110300
Total Memory Usage: 17 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 1843

Also, you may try changing your intelliSenseMode to "windows-gcc-x64" to see if that helps.

Changing intelliSenseMode and restarting VSCode didn't help.

@sean-mcmanus
Copy link
Contributor

Can you do a search under C:\PROGRAM FILES\CYGWIN64\ for a file named stddef.h?

@jantajov
Copy link
Author

jantajov commented Nov 4, 2022

Sure no problem:

PS C:\Program Files\CygWin64> Get-ChildItem -r -fi stddef.h


    Directory: C:\Program Files\CygWin64\lib\gcc\x86_64-pc-cygwin\11\include


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        02/05/2022  12:25 PM          12959 stddef.h

@sean-mcmanus
Copy link
Contributor

For some reason, our compiler query is not returning C:\Program Files\CygWin64\lib\gcc\x86_64-pc-cygwin\11\include. Are you able to fix the issue via adding that path to the includePath?

    "includePath": [
        "${workspaceFolder}/**",
        "C:\\Program Files\\CygWin64\\lib\\gcc\\x86_64-pc-cygwin\\11\\include"
    ],

@jantajov
Copy link
Author

jantajov commented Nov 5, 2022

Well, yes it works.
But...
That isn't a real fix for the issue. There might be more paths that need to be included. Why is VS Code compiler query failing to find all inclusion paths?

Are you able to reproduce the issue on your local machine, so you could take a closer look?

In my original comment I have linked the archive with the whole CygWin environment. Perhaps you could spin up Windows Sandbox, install VSCode there and unpack my CygWin archive in C:\Program Files\CygWin64.

@sean-mcmanus sean-mcmanus added investigate: repro This issue's repro steps needs to be investigated/confirmed and removed more info needed The issue report is not actionable in its current state labels Nov 5, 2022
@sean-mcmanus sean-mcmanus added this to the On Deck milestone Nov 5, 2022
@sean-mcmanus sean-mcmanus removed their assignment Nov 5, 2022
@Colengms
Copy link
Contributor

Colengms commented Nov 7, 2022

It looks like this version of Cygwin returns include (full) paths under a /cygdrive path, which I've never seen before.

c:\Program Files\CygWin64\bin>"c:\program files\cygwin64\bin\gcc.exe" -std=c++17 -m64 -Wp,-v -E -dM -x c++ /dev/null
...
 /cygdrive/c/program files/cygwin64/bin/../lib/gcc/x86_64-pc-cygwin/11/include/c++
 /cygdrive/c/program files/cygwin64/bin/../lib/gcc/x86_64-pc-cygwin/11/include/c++/x86_64-pc-cygwin
 /cygdrive/c/program files/cygwin64/bin/../lib/gcc/x86_64-pc-cygwin/11/include/c++/backward
 /cygdrive/c/program files/cygwin64/bin/../lib/gcc/x86_64-pc-cygwin/11/include
 /usr/include
 /usr/lib/../lib/../include/w32api
...

Using this issue to track adding support for full paths under /cygdrive.

@Colengms Colengms self-assigned this Nov 7, 2022
@Colengms Colengms added fixed Check the Milestone for the release in which the fix is or will be available. and removed investigate: repro This issue's repro steps needs to be investigated/confirmed labels Nov 7, 2022
@Colengms Colengms modified the milestones: On Deck, 1.13.4 Nov 9, 2022
@Colengms Colengms changed the title Cannot open source file stddef.h" (dependency of stdlib.h) Add support for /cygdrive paths returned by some versions of Cygwin Nov 9, 2022
@sean-mcmanus
Copy link
Contributor

Fixed with 1.13.4 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.4

@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

3 participants