Sign in to follow this  

GCC switches

This topic is 3487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
-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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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").

Share this post


Link to post
Share on other sites

This topic is 3487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this