Skip to content

The wildcard can't be used by the C/C++ compiler recommanded! #13096

Closed

Description

When I browsed the doc of GCC on Windows,I found that I could modify my tasks.json file to build multiple C++ files by using an argument like "${workspaceFolder}/*.cpp" instead of "${file}". But there is a fatal error when I run my program. The information is that *.cpp is invalid argument.

What is interesting is that my program runs sucessfully if I use another compiler downloaded from https://winlibs.com/.
Image

Activity

  1. WangShiSuiFeng24 commented on Dec 28, 2024

    @WangShiSuiFeng24
    Author

    The recommanded compiler is installed by msys2 with the command line "pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
    "
    Image

  2. browntarik commented on Jan 2, 2025

    @browntarik
    Contributor

    Could you provide more information about this compiler you are using? What is the exact path of "g++" in the command line?

    Does this repro when you use the full path to the ucrt version of the compiler (i.e "C:/msys64/ucrt64/bin/g++.exe") in the command line?

    Does the issue reproduce without using the cppbuild task and just the command line?

  3. self-assigned this
    on Jan 2, 2025
  4. WangShiSuiFeng24 commented on Jan 4, 2025

    @WangShiSuiFeng24
    Author

    Yes, g++ means D:\msys64\ucrt64\bin\g++.exe which is downloaded by msys2 that vscode document recommended.
    I have tried many times in the command line and also in tasks.json.
    You can download the msys2 and then input the command "pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
    " according to https://code.visualstudio.com/docs/cpp/config-mingw.
    Finally, at windows10 environment, you can try the command "g++ *.cpp -o filename.exe". There will be a fatal error.

  5. browntarik commented on Jan 4, 2025

    @browntarik
    Contributor

    If the issue reproduces when you just use the command line, then the issue may have to do with your shell and not our extension. I am not able to reproduce your behavior using the same compiler.

    It wasn't clear based on your response if you have tried compiling with the full path. Can you confirm that doesn't work?

    Did you ensure the ucrt compiler was added to your PATH environment variable?

  6. WangShiSuiFeng24 commented on Jan 5, 2025

    @WangShiSuiFeng24
    Author

    No,the issue also happened in tasks.json. The shell is powershell of windows10.
    I did add the ucrt compiler to the PATH environment variable. I can be sure that I also tried full path command compile. That made a fatal error.
    I have also communicated with some friends on the internet. They also found there is a fatal error.
    pwsh
    Image
    cmd
    Image
    tasks.json
    Image

  7. SainoNamkho commented on Jan 5, 2025

    @SainoNamkho

    If the issue reproduces when you just use the command line, then the issue may have to do with your shell and not our extension. I am not able to reproduce your behavior using the same compiler.

    It wasn't clear based on your response if you have tried compiling with the full path. Can you confirm that doesn't work?

    Did you ensure the ucrt compiler was added to your PATH environment variable?

    This issue is about documentation rather than cpptools itself. Maybe https://github.com/microsoft/vscode-docs/issues is the better place to report it.

    https://code.visualstudio.com/docs/cpp/config-mingw recommends using gcc from msys2, which was not configured with --enable-mingw-wildcard, thus the wildcard expansion only works in msys bash shell, not the integrated terminal where tasks.json is used.

    However gcc from winlibs is configured with --enable-mingw-wildcard.

  8. truongan012 commented on Jan 6, 2025

    @truongan012

    It's disabled by msys2 as default ;(
    https://www.msys2.org/news/#2024-11-03-disabling-mingw-w64-wildcard-support-by-default

    I dont know how to enable it again!?

  9. browntarik commented on Jan 6, 2025

    @browntarik
    Contributor

    If the issue reproduces when you just use the command line, then the issue may have to do with your shell and not our extension. I am not able to reproduce your behavior using the same compiler.
    It wasn't clear based on your response if you have tried compiling with the full path. Can you confirm that doesn't work?
    Did you ensure the ucrt compiler was added to your PATH environment variable?

    This issue is about documentation rather than cpptools itself. Maybe https://github.com/microsoft/vscode-docs/issues is the better place to report it.

    https://code.visualstudio.com/docs/cpp/config-mingw recommends using gcc from msys2, which was not configured with --enable-mingw-wildcard, thus the wildcard expansion only works in msys bash shell, not the integrated terminal where tasks.json is used.

    However gcc from winlibs is configured with --enable-mingw-wildcard.

    SainoNamkho Thank you for providing this additional context, it looks like MSYS2 decided to change their compiler behavior at the end of the year. We will update our documentation to reflect this change in behavior.

  10. added
    docsIssue related to documentation about the extension
    and removed
    more info neededThe issue report is not actionable in its current state
    on Jan 6, 2025
  11. moved this to Todo in cpptoolson Jan 6, 2025
  12. WangShiSuiFeng24 commented on Jan 7, 2025

    @WangShiSuiFeng24
    Author

    This issue seems to be over. Thank you all for answering my questions.

  13. moved this from Todo to Done in cpptoolson Jan 7, 2025
  14. locked and limited conversation to collaborators on Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Language ServicedocsIssue related to documentation about the extension

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions