gcc compiler question

This is a discussion on gcc compiler question within the C Programming forums, part of the General Programming Boards category; does anyone know the command line syntax for the gcc compiler to output the compiler errors to a file?...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    60

    gcc compiler question

    does anyone know the command line syntax for the gcc compiler to output the compiler errors to a file?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You use file redirection based on your OS. Typically something like:
    Code:
    gcc -o foo foo.c -Wall -pedantic -ansi >& foo.txt
    But this isn't a compiler issue. It's just redirection. If there is such a flag, I haven't bothered to look for it, because redirection does it for me.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    57
    I too redirect;
    gcc prog.c -o prog.exe >somefile.txt

    I looked throught the gcc documentation and could not find
    an output for just errors:

    http://gcc.gnu.org/onlinedocs

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    60
    Thanks...I tried the

    gcc prog.c -o prog.ex > somefile.txt

    ...and it created the file but the file was empty. I tried looking at their documentation too and I couldn't find anything either. I'm running this through Cygwin on my Win XP box.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So how about trying what I told you to try? I don't just make all this ........ up you know.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    60
    Sorry...I was responding to the second poster first. I tried yours and it worked. I had to move the -o in the syntax. The -o went between somefile.c and somefile.exe. I then included what you stated and it worked so thank you.

  7. #7
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    The -o just has to go before the target executable, because it specifies the output file. Conventially, most people do:
    Code:
    gcc -o <name of executable> <source file(s)> <flags>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GCC compiler giving syntax error before 'double' error
    By dragonmint in forum Linux Programming
    Replies: 4
    Last Post: 06-02-2007, 05:38 PM
  2. More of a GCC question
    By elliptic in forum C Programming
    Replies: 4
    Last Post: 06-01-2006, 02:29 AM
  3. gcc or g++ Question
    By TK in forum Linux Programming
    Replies: 3
    Last Post: 07-17-2002, 10:36 AM
  4. C/C++ Compiler Question
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 07-09-2002, 02:09 AM
  5. Question: Which Compiler????
    By MaBo in forum C Programming
    Replies: 5
    Last Post: 06-04-2002, 11:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21