-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a page about mingw-w64 wildcard expansion
We want to change the default, so add some docs we can point to in the upcoming NEWS entry.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# C/C++ | ||
|
||
## Expanding wildcard arguments | ||
|
||
For making your program accept wildcard arguments, the official MSVC way is to | ||
link [w]setargv.obj to your program. By default it is not enabled. For more | ||
details see | ||
https://learn.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments | ||
|
||
With mingw-w64 there are three ways wildcard expansion con be configured: | ||
|
||
1. mingw-w64 can be configured at build time to either enable or disable wildcard expansion by default via the `--enable-wildcard` configure flags. This can to be overridden on a per .exe basis by the user. | ||
|
||
Currently wildcard expansion is enabled by default in MSYS2. | ||
|
||
2. You can set `_dowildcard` in your source code to either `0` or `-1` to disable or enable wildcard expansion. | ||
|
||
```c | ||
// To force-enable wildcard expansion | ||
int _dowildcard = -1; | ||
// To force-disable wildcard expansion | ||
int _dowildcard = 0; | ||
``` | ||
|
||
3. You can link in `CRT_noglob.o` or `CRT_noglob.o` to disable or enable wildcard expansion. This will error out if `_dowildcard` is already set in the source. | ||
|
||
```bash | ||
# To enable force-enable wildcard expansion | ||
gcc main.c $(clang -print-file-name=CRT_glob.o) | ||
# To force-disable wildcard expansion | ||
gcc main.c $(clang -print-file-name=CRT_noglob.o) | ||
``` |