RE: -x option for gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Anitha Boyapati wrote:
>    I fail to understand the use of x option  if all it does is to 
>    interpret the file by means of given language.Can you 
> please shed some 
>    more light on it.

I don't understand the source of your difficulties.

The -x option is there for situations when the compiler front end cannot
figure out the type of a file. Perhaps the suffix is missing, or is
incorrect or nonstandard. One situation may be that there is no suffix,
because standard input is being read.

For instance

  mymachine $ gcc -x c -
  #include <stdio.h>
  ... type hello world main() here
  ... then Ctrl-D
  mymachine $ ./a.out
  Hello, world!

Without the -x, how would gcc know that you are typing in the C
language, right?

The -x <lang> option does not mean ``behave as a complete front-end for
language X''. It just means ``interpret files as if they were of this
language''.

Note that in

   gcc -x c++ test.cc

the ``-x c++'' is redundant because the same information is deduced from
the .cc suffix already.

If you want to find out what external symbols are needed by a program,
then compile it to .o files, and then try to link with -nodefaultlibs:

   g++ -c *.cc
   gcc -nodefaultlibs *.o

Then examine the unresolved symbol error messages.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux