Skip to content

Commit

Permalink
Add a page about mingw-w64 wildcard expansion
Browse files Browse the repository at this point in the history
We want to change the default, so add some docs we can point
to in the upcoming NEWS entry.
  • Loading branch information
lazka committed Oct 29, 2024
1 parent 89521b9 commit 2468c51
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ nav:
- docs/autotools.md
- docs/python.md
- docs/git.md
- docs/c.md
- docs/cpp.md
- docs/pkgconfig.md
- docs/pacman.md
Expand Down
32 changes: 32 additions & 0 deletions web/docs/c.md
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
cc main.c $(cc -print-file-name=CRT_glob.o)
# To force-disable wildcard expansion
cc main.c $(cc -print-file-name=CRT_noglob.o)
```

0 comments on commit 2468c51

Please sign in to comment.