Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Greg Chicares <chicares-j9pdmedNgrk <at> public.gmane.org>
Subject: Whitespace in '-x language' gcc option
Newsgroups: gmane.comp.gnu.mingw.user
Date: Saturday 12th August 2006 15:14:21 UTC (over 11 years ago)
The gcc manual
  http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Overall-Options.html#Overall-Options
writes a space between '-x' and its argument:
| -x language
| -x none
but '-x c++' doesn't work with '.h' files, while writing it without
any space does work.

Here are some files that must be syntactically valid:

  C:/tmp[0]$touch eraseme.h eraseme.hpp
  C:/tmp[0]$ls -o eraseme.h*
  -rw-rw-rw-   1 Win32           0 Aug 12 14:44 eraseme.h
  -rw-rw-rw-   1 Win32           0 Aug 12 14:44 eraseme.hpp

With a space after '-x', the '.hpp' file compiles, but the '.h' file
gives a diagnostic:

  C:/tmp[0]$/MinGW-20050120/bin/g++ -x c++ -fsyntax-only eraseme.hpp
  C:/tmp[0]$/MinGW-20050120/bin/g++ -x c++ -fsyntax-only eraseme.h
  cc1plus.exe: error: output filename specified twice

Permuting the options doesn't help:

  C:/tmp[0]$/MinGW-20050120/bin/g++ -x c++ eraseme.h -fsyntax-only
  cc1plus.exe: error: output filename specified twice
  C:/tmp[1]$/MinGW-20050120/bin/g++ -fsyntax-only -x c++ eraseme.h
  cc1plus.exe: error: output filename specified twice

Removing the whitespace does seem to work:

  C:/tmp[1]$/MinGW-20050120/bin/g++ -xc++ -fsyntax-only eraseme.hpp
  C:/tmp[0]$/MinGW-20050120/bin/g++ -xc++ -fsyntax-only eraseme.h
  C:/tmp[0]$

Indeed, it actually does work:

  C:/tmp[0]$echo 'size_t foo();' >eraseme.h
  C:/tmp[0]$/MinGW-20050120/bin/g++ -xc++ -fsyntax-only eraseme.h
  eraseme.h:1: error: `size_t' does not name a type

And it works with a more recent version, too, which still requires
the space:

  C:/tmp[1]$/MinGW-20060119/bin/g++ -xc++ -fsyntax-only eraseme.h
  eraseme.h:1: error: `size_t' does not name a type
  C:/tmp[1]$/MinGW-20060119/bin/g++ -x c++ -fsyntax-only eraseme.h
  cc1plus.exe: error: output filename specified twice

I'm leery of this: the manual also says

  http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Invoking-GCC.html#Invoking-GCC
| Many options have multi-letter names; therefore multiple single-
| letter options may not be grouped: -dr is very different from `-d -r'.

and '-x' and '-c' are indeed distinct options, though presumably
there's no '-xc' option (for now at least--but someone could
conceivably add '-xcompiler=' for a cross compiler). And I think
I remember running into a problem writing '-xc++' in the distant
past, so I've been taking care to write '-x c++'.

In case anyone's wondering what I'm trying to accomplish, I'm
testing for the property Lakos called 'transitive closure' IIRC:
verifying that every header compiles on a standalone basis.
I've been doing this with '.hpp' headers only, but added a '.h'
header today.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
MinGW-users mailing list
[email protected]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
 
CD: 3ms