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

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

Open
WangShiSuiFeng24 opened this issue Dec 28, 2024 · 6 comments
Open

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

WangShiSuiFeng24 opened this issue Dec 28, 2024 · 6 comments
Assignees
Labels
Language Service more info needed The issue report is not actionable in its current state

Comments

@WangShiSuiFeng24
Copy link

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

@WangShiSuiFeng24
Copy link
Author

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

@ntrogh ntrogh transferred this issue from microsoft/vscode-docs Jan 2, 2025
@browntarik
Copy link
Contributor

browntarik commented Jan 2, 2025

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?

@browntarik browntarik self-assigned this Jan 2, 2025
@browntarik browntarik added more info needed The issue report is not actionable in its current state Language Service labels Jan 2, 2025
@WangShiSuiFeng24
Copy link
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.

@browntarik
Copy link
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?

@WangShiSuiFeng24
Copy link
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

@SainoNamkho
Copy link

SainoNamkho commented Jan 5, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Service more info needed The issue report is not actionable in its current state
Projects
Status: No status
Development

No branches or pull requests

3 participants