Skip to content

Commit 536e20e

Browse files
authored
Merge pull request MicrosoftDocs#3293 from corob-msft/docs/corob/cpp-docs-2585-followup
Rewrite of command line parsing docs per cpp-docs 2585
2 parents 4561e6b + af674dc commit 536e20e

File tree

3 files changed

+99
-96
lines changed

3 files changed

+99
-96
lines changed
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
---
2-
title: "Customizing C Command-Line Processing"
3-
ms.date: "11/04/2016"
2+
title: "Customizing C command-line processing"
3+
description: "How to suppress `main` function argument and environment parameter handling in the runtime startup code."
4+
ms.date: 11/19/2020
45
helpviewer_keywords: ["_spawn functions", "command line, processing", "command-line processing", "startup code, customizing command-line processing", "environment, environment-processing routine", "_setargv function", "command line, processing arguments", "suppressing environment processing", "_exec function"]
5-
ms.assetid: c20fa11d-b35b-4f3e-93b6-2cd5a1c3c993
66
---
7-
# Customizing C Command-Line Processing
7+
# Customizing C command-line processing
88

9-
If your program does not take command-line arguments, you can save a small amount of space by suppressing use of the library routine that performs command-line processing. This routine is called **_setargv** (or **_wsetargv** in the wide-character environment), as described in [Expanding Wildcard Arguments](../c-language/expanding-wildcard-arguments.md). To suppress its use, define a routine that does nothing in the file containing the **main** function and name it **_setargv** (or **_wsetargv** in the wide-character environment). The call to **_setargv** or **_wsetargv** is then satisfied by your definition of **_setargv** or **_wsetargv** , and the library version is not loaded.
9+
If your program doesn't take command-line arguments, you can suppress the command-line processing routine to save a small amount of space. To suppress its use, include the *`noarg.obj`* file (for both `main` and `wmain`) in your **`/link`** compiler options or your **`LINK`** command line.
1010

11-
Similarly, if you never access the environment table through the `envp` argument, you can provide your own empty routine to be used in place of **_setenvp** (or **_wsetenvp**), the environment-processing routine.
11+
Similarly, if you never access the environment table through the *`envp`* argument, you can suppress the internal environment-processing routine. To suppress its use, include the *`noenv.obj`* file (for both `main` and `wmain`) in your **`/link`** compiler options or your **`LINK`** command line.
1212

13-
If your program makes calls to the **_spawn** or **_exec** family of routines in the C run-time library, you should not suppress the environment-processing routine, since this routine is used to pass an environment from the spawning process to the new process.
13+
For more information on runtime startup linker options, see [Link options](../c-runtime-library/link-options.md).
14+
15+
Your program might make calls to the `spawn` or `exec` family of routines in the C runtime library. If it does, you shouldn't suppress the environment-processing routine, since it's used to pass an environment from the parent process to the child process.
1416

1517
## See also
1618

17-
[main Function and Program Execution](../c-language/main-function-and-program-execution.md)
19+
[`main` function and program execution](../c-language/main-function-and-program-execution.md)\
20+
[Link options](../c-runtime-library/link-options.md).
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
---
2-
title: "Expanding Wildcard Arguments"
3-
ms.date: "11/04/2016"
2+
title: "Expanding wildcard arguments"
3+
description: "How to use a linker option to process wildcard command-line arguments in your programs."
4+
ms.date: 11/20/2020
45
helpviewer_keywords: ["asterisk wildcard", "question mark, wildcard", "expanding wildcard arguments", "wildcards, expanding"]
5-
ms.assetid: 80a11c4b-0199-420e-a342-cf1d803be5bc
66
---
7-
# Expanding Wildcard Arguments
7+
# Expanding wildcard arguments
88

9-
**Microsoft Specific**
9+
Wildcard argument expansion is Microsoft-specific.
1010

11-
When you run a C program, you can use either of the two wildcardsthe question mark (?) and the asterisk (*) — to specify filename and path arguments on the command line.
11+
When you run a C program, you can use either of the two wildcards, the question mark (**`?`**) and the asterisk (**`*`**), to specify filename and path arguments on the command line.
1212

13-
By default, wildcards are not expanded in command-line arguments. You can replace the normal argument vector `argv` loading routine with a version that does expand wildcards by linking with the setargv.obj or wsetargv.obj file. If your program uses a `main` function, link with setargv.obj. If your program uses a `wmain` function, link with wsetargv.obj. Both of these have equivalent behavior.
13+
By default, wildcards aren't expanded in command-line arguments. You can replace the normal argument vector `argv` loading routine with a version that does expand wildcards by linking with the *`setargv.obj`* or *`wsetargv.obj`* file. If your program uses a `main` function, link with *`setargv.obj`*. If your program uses a `wmain` function, link with *`wsetargv.obj`*. Both of these have equivalent behavior.
1414

15-
To link with setargv.obj or wsetargv.obj, use the **/link** option. For example:
15+
To link with *`setargv.obj`* or *`wsetargv.obj`*, use the **`/link`** option. For example:
1616

17-
**cl example.c /link setargv.obj**
17+
**`cl example.c /link setargv.obj`**
1818

19-
The wildcards are expanded in the same manner as operating system commands. (See your operating system user's guide if you are unfamiliar with wildcards.)
20-
21-
**END Microsoft Specific**
19+
The wildcards are expanded in the same manner as operating system commands.
2220

2321
## See also
2422

25-
[Link Options](../c-runtime-library/link-options.md)<br/>
26-
[main Function and Program Execution](../c-language/main-function-and-program-execution.md)
23+
[Link options](../c-runtime-library/link-options.md)\
24+
[`main` function and program execution](../c-language/main-function-and-program-execution.md)

0 commit comments

Comments
 (0)