-
March 28th, 2019, 04:50 AM
#1
Is it possible to send verbose o/p of gcc to text file instead of standard output?
I am trying to run the command :
$ gcc --save-temps --verbose ex1.c -o ex1__
and want to save the result in text file rather for easy reference later.
Am using cygwin 7.3.0, with GNU C version 7.3.0.
-
March 28th, 2019, 05:57 AM
#2
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
$ gcc --save-temps --verbose ex1.c -o ex1__ 2>&1 | tee a.txt
The above works, but would like to know if any other way exists too, or not. If not, then why not.
Last edited by ajiten73; March 28th, 2019 at 06:00 AM.
-
March 28th, 2019, 05:59 AM
#3
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Wouldn't normal input redirection work? Say:
Code:
$ gcc --save-temps --verbose ex1.c -o ex1 2> gcc_errors.txt
-
March 28th, 2019, 08:30 AM
#4
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Originally Posted by laserlight
Wouldn't normal input redirection work? Say:
Code:
$ gcc --save-temps --verbose ex1.c -o ex1 2> gcc_errors.txt
No, the text file is just created but empty. For a new file (not created yet) used >, but failed. Even using >> (so as to append contents) does not help.
-
March 28th, 2019, 08:39 AM
#5
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
When dealing with the console, there are 3 standard streams.
0 - stdin
1 - stdout
2 - srderr
To redirect stdout to a file use > {fn} (to overwrite) or >>{fn} (to append). To redirect stderr use 2> {fn} (or 2>> {fn}). To redirect stdin use < {fn}.
By default, both stdout and stderr show their output to the console.
PS, in your post #2, 2> &1 | tee a.txt
This causes stderr to go to stdout. stdout is piped (|) to the program tee as stdin. Tee gets its input from stdin (| effectively connects stdout to stdin) and writes its output to both stdout and to the specified file (a.txt).
Last edited by 2kaud; March 28th, 2019 at 09:23 AM.
Reason: PS
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2019, 09:21 AM
#6
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Originally Posted by 2kaud
When dealing with the console, there are 3 standard streams.
0 - stdin
1 - stdout
2 - srderr
To redirect stdout to a file use > {fn} (to overwrite) or >>{fn} (to append). To redirect stderr use 2> {fn} (or 2>> {fn}). To redirect stdin use < {fn}.
By default, both stdout and stderr show their output to the console.
I expected the same, but it leads to a new file (if not already there, with >) which is empty, or causes no change with >> to an existing file.
I am sorry, but request confirmation for {fn}. I expect it as abbreviation for {file name}.
-
March 28th, 2019, 09:23 AM
#7
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
I am sorry, but request confirmation for {fn}. I expect it as abbreviation for {file name}.
Yes. Also my PS to my post #5.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2019, 09:25 AM
#8
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
I expected the same, but it leads to a new file (if not already there, with >) which is empty, or causes no change with >> to an existing file.
Do you still get anything showing on the console?
PS you don't have a space between the 2 and the > do you? It needs to be 2> with no space. 2 > means something different!
Last edited by 2kaud; March 28th, 2019 at 09:28 AM.
Reason: PS
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2019, 09:43 AM
#9
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Originally Posted by 2kaud
Do you still get anything showing on the console?
PS you don't have a space between the 2 and the > do you? It needs to be 2> with no space. 2 > means something different!
$ gcc --save-temps --verbose ex1.c -o ex1__ 2>&1 | tee a.txt
There is no space between '2' & '>'.
Would request the meaning (action generated by) of '2 > '.
-
March 28th, 2019, 09:45 AM
#10
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
2 > means use 2 as a command-line parameter and redirect stdout (instead of 2> which redirects stderr!).
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 28th, 2019, 10:11 AM
#11
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Originally Posted by 2kaud
2 > means use 2 as a command-line parameter and redirect stdout (instead of 2> which redirects stderr!).
Thanks a lot. Please tell where to look for such information. I request that if some googling term be stated for the same, then even better.
-
March 28th, 2019, 11:29 AM
#12
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
See https://support.microsoft.com/en-us/...-stderr-stdout
If you search https://msdn.microsoft.com/en-us/ with relevant search terms, you usually find required info.
There's also years of experience!
Last edited by 2kaud; March 28th, 2019 at 11:33 AM.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|