Skip to content

Commit 3cbbf79

Browse files
committed
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.
1 parent 89521b9 commit 3cbbf79

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ nav:
118118
- docs/autotools.md
119119
- docs/python.md
120120
- docs/git.md
121+
- docs/c.md
121122
- docs/cpp.md
122123
- docs/pkgconfig.md
123124
- docs/pacman.md

web/docs/c.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# C/C++
2+
3+
## Expanding wildcard arguments
4+
5+
For making your program accept wildcard arguments, the official MSVC way is to
6+
link [w]setargv.obj to your program. By default it is not enabled. For more
7+
details see
8+
https://learn.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments
9+
10+
With mingw-w64 there are three ways wildcard expansion con be configured:
11+
12+
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.
13+
14+
Currently wildcard expansion is enabled by default in MSYS2.
15+
16+
2. You can set `_dowildcard` in your source code to either `0` or `-1` to disable or enable wildcard expansion.
17+
18+
```c
19+
// To force-enable wildcard expansion
20+
int _dowildcard = -1;
21+
// To force-disable wildcard expansion
22+
int _dowildcard = 0;
23+
```
24+
25+
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.
26+
27+
```bash
28+
# To enable force-enable wildcard expansion
29+
cc main.c $(cc -print-file-name=CRT_glob.o)
30+
# To force-disable wildcard expansion
31+
cc main.c $(cc -print-file-name=CRT_noglob.o)
32+
```

0 commit comments

Comments
 (0)