Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #75768

Re: Outputting error messages with 2<

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Outputting error messages with 2<
Date 2015-11-11 11:47 -0500
Organization Self
Message-ID <5643713F.20901@verizon.net> (permalink)
References <f1def472-ef12-4282-b004-17118d299e00@googlegroups.com>

Show all headers | View raw


On 11/11/2015 09:18 AM, Alla _ wrote:
> Hello!
> 
> I have just seen in the lecture that to output all error messages 
> generated by compiler, I have to use 2< at the command line. 
> 
> Unfortunately, no other technical details were provided. 

My best guess is that you were told to use "2>", not "2<". I would also
guess that you were not told to do this in order to "output all error
messages". That is something that normally happens without taking any
special measures. In many Unix shells, using "2>filename" on the command
line causes any output to file number 2 (stderr, which is normally sent
to the screen) to be re-directed to the specified filename instead. I
suspect, therefore, that you were told to use this to save the error
messages, not to output them.

I personally use tcsh as my shell, which is descended from csh, and
neither of them supports this syntax.

> If I want to output the result of my program into, say, a txt file,
> I can type:
> ./nameofprogram > output.txt
> 
> But how can I output all error messages, if the compiler generates 
> error messages only when it can't compile a program, and, hence, no object
> file exists; therefore I can't run ./nameofprogram 2> output.txt, because
> nameofprogram.exe doesn't exist.

You say that you were told to do this to look at "error messages
generated by the compiler". So this is something that you should do when
compiling your program, not when you run it. It is therefore something
that you can do even if the compilation fails:

  cc $CFLAGS nameofprogram.c -o nameofprogram.exe 2> output.txt

You mentioned that "no object file exists" and later "because
nameofprogram.exe doesn't exist" - did you think you were talking about
the same thing with both of those comments? Most compilers I've used are
flexible enough that you can name the object files anything you want -
but it's conventional for object files on Unix platforms to have names
that end in ".o". Names that end in ".exe" are usually used only for
executables, not for object files. Also, ".exe" is also more popular
among people who are used to Windows naming conventions - native
executables on Unix-like systems seldom have any special extension.
Executables are normally identified as such by the fact that they have
the "file execute" permission bit set, not by naming conventions.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Outputting error messages with 2< Alla _ <modelling.data@gmail.com> - 2015-11-11 06:18 -0800
  Re: Outputting error messages with 2< Richard Damon <Richard@Damon-Family.org> - 2015-11-11 09:38 -0500
  Re: Outputting error messages with 2< Mark Storkamp <mstorkamp@yahoo.com> - 2015-11-11 08:44 -0600
  Re: Outputting error messages with 2< James Kuyper <jameskuyper@verizon.net> - 2015-11-11 11:47 -0500
    Re: Outputting error messages with 2< David Thompson <dave.thompson2@verizon.net> - 2015-12-06 08:01 -0500
      Re: Outputting error messages with 2< James Kuyper <jameskuyper@verizon.net> - 2015-12-06 10:21 -0500

csiph-web