GCC switches

Started by
8 comments, last by Punchin Deck 15 years, 11 months ago
Evening, This is my first post!. So "Hello, World!" to you all :). Right. I'm not specifically having a problem per se, but I would like to know how display the filenames that the GCC compiler (version 4.2.1) is compiling. BTW I'm using the command-line version of the compiler. At the moment it is just compiling the files and then exiting and I would like a visual representation of what has actually been compiled (a-la MSVC). I've been looking though the documentation all afternoon and I can't find anything that suites my needs. I'm very frustrated. Hopes you can help.
Advertisement
gcc will always compile all its arguments—so, you could just print the list of files sent to the compiler and that would be it. For instance, if you're running:

gcc *.c

Then you'd get the list of compiled files with:

ls *.c

Of course, if the files are dynamically chosen and sent to gcc by a make system, then you'd have to configure that make system to echo the executed commands.
Quote:Original post by Punchin Deck
Evening,

This is my first post!. So "Hello, World!" to you all :). Right. I'm not specifically having a problem per se, but I would like to know how display the filenames that the GCC compiler (version 4.2.1) is compiling. BTW I'm using the command-line version of the compiler. At the moment it is just compiling the files and then exiting and I would like a visual representation of what has actually been compiled (a-la MSVC). I've been looking though the documentation all afternoon and I can't find anything that suites my needs. I'm very frustrated.

Hopes you can help.


Unix programs tend to be silent and only output information if there is a problem or error. Seeing as GCC is a program designed for Unix like operating systems it takes its philosophy from it.

I'm unaware of a command that will list the files it is compiling as it does it. I'm not actually sure why you would want to know either?

As previously said, usually you just watch the commands executed - there is probably no way to do what you want.

How do you invoke gcc?
Quote:Original post by ToohrVyk
gcc will always compile all its arguments—so, you could just print the list of files sent to the compiler and that would be it. For instance, if you're running:
gcc *.c
Thats basically what I'm doing as opposed to putting a huge list of files on the command line. I suppose having thought about I could actually build each file but that would just restort in a huge list of gcc commands. So thats just a matter of preference.
Quote:I'm unaware of a command that will list the files it is compiling as it does it. I'm not actually sure why you would want to know either?
It's not essential its just merely a preference. Rather than seeing nothing I would like to see something happening. But still if that is the case then I'll take it then that it can't be done.

Many thanks for the advice.
You could just write your own makefiles. They get the job done and allow for some complex compilation procedures, as well as saving on typing in the long run.

They would also allow you to echo each command I think as it is executed showing you the progress. That might be your best option.
-v (verbose) will print out each individual file compilation command - but it will also print out a ton of other stuff you probably don't want.

If you're in a *nix (Unix/Linux etc) environment you can pipe that output to something like grep.

EDIT: You could also (again if using a good *nix shell) write a shell loop that does the work for you. I haven't made one in a long time so i forget exact syntax but basically it'd be like:

for $i in *.c
do
echo $i
gcc $i
done

will first echo the filename to the console, then call gcc on the file, for each file matching the for loop
Quote:Original post by Cromulent
You could just write your own makefiles. They get the job done and allow for some complex compilation procedures, as well as saving on typing in the long run.

They would also allow you to echo each command I think as it is executed showing you the progress. That might be your best option.
Sounds as close as I'm going get. However I'm really a newbie when it comes to building makefiles. In fact I've not written any. Know any good resources?. That would be really helpful.

Thanks.

Quote:Original post by Punchin Deck
I suppose having thought about I could actually build each file but that would just restort in a huge list of gcc commands. So thats just a matter of preference.


not quite

If you are actually using a ccache (caching compiled/precompiled files) or make they tests for changes/timestamps of the files to compile. So if you compile each file every time this results in recompiles where no changes are.

€:
if (languagespoken(you) == german) {
visit("http://www.ijon.de/comp/tutorials/makefile.html");
else
visit("google.com").
Quote:Original post by hydroo
if (languagespoken(you) == german) {
visit("http://www.ijon.de/comp/tutorials/makefile.html");
else
visit("google.com").

return("great thanks");

This topic is closed to new replies.

Advertisement