Restriction: This section does not apply to AMODE 64.
In the default inheritance model, the behavior of C standard streams is such that a child main() function cannot affect the standard streams of the parent. The child can use the parent's definition or redirect a standard stream to a new location, but when control returns to the parent, the standard stream reverts back to the definition of the parent. In the global model, the C standard streams, stdin, stdout, and stderr, can be redirected to a different location while running in a child main() function and have that redirection stay in effect when control returns to the parent. You can use the _EDC_GLOBAL_STREAMS environment variable to set standard stream behavior to the global model. For more information, see _EDC_GLOBAL_STREAMS.
Behavior | Default Inheritance Model | Global Model |
---|---|---|
POSIX(OFF) | Standard streams are opened automatically on first reference. | (Same) |
POSIX(ON) | Standard streams are opened during initialization of the process, before the application receives control. | Not supported. |
default open modes | As described in Default open modes. | (Same) |
default locations | As described in this topic. | (Same) |
command line redirection | Changes the location for the main being called and subsequent child programs. | Changes the location for the entire C environment. |
direct assignment | Affects the current main and subsequent child programs. | Affects the current main only. This definition is not passed on to a subsequent child program. The child gets the current global definition, if there is one defined. |
freopen() | Changes location for the main from which it is called and affects any subsequent child programs. | Changes location for the entire C environment. |
MSGFILE() runtime option | Redirects stderr for the main being invoked and affects any subsequent child programs. When control returns to a parent program, stderr reverts back to the definition of the parent. If stderr is also redirected on the command line, that redirection takes precedence. | (Same) |
fclose() | Closes the standard stream in current main only. | Closes the standard stream for the entire C environment. The standard stream cannot be global anymore. Only direct assignment can be used to use the standard stream, and that would only be for the main in which it is assigned. |
file position and visible data | As currently described in this topic. | File position and visible data across mains are as if there were only one main. No special processing occurs during the ANSI system() call. The standard streams are left untouched. When either entering or returning from a child program, reading or writing to the standard streams begin where previously left off, |
C++ I/O Stream | cin defaults to stdin |
(Same) |