delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/04/06:35:35

Date: Thu, 4 Sep 1997 12:30:29 +0200 (METDST)
From: Robert Hoehne <robert DOT hoehne AT Mathematik DOT TU-Chemnitz DOT DE>
To: djgpp AT delorie DOT com
Subject: Compiling .cpp files (another hint of the week)
Message-Id: <Pine.HPP.3.95q.970904122859.23558C-100000@newton.mathematik.tu-chemnitz.de>
Mime-Version: 1.0

To fix the bug in gcc with the incorrect handling of of the
-dumpbase argument when compiling C++ source files which have
an other suffix than .cc, symply cut the text below and append
it to you specs file (normally %DJDIR%/lib/specs). This is not
a bug with the compile stage but you will see this bug, when you
try to debug your program with GDB/RHIDE/RHGDB.

The sample below fixes the common usage of .cpp files. If you
want to compile for instance .cxx files, replace the first
.cpp with .cxx and then search for -dumpbase and replace after it
%b.cpp with %b.cxx

Now yu can ask me, from where I came to this fix. This is "simple"!
After looking in 'gcc.c' I guessed how gcc reads the specs file. Then
I thought that it should be possible to overwrite any default compiler
spec for gcc in that file. So Ivo Janssen
tried it with success and here is now the result, which is simply the
default spec for compiling C++ source files by replacing .cc with .cpp

------CUT HERE-----

.cpp:
cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
 %{C:%{!E:%eGNU C++ does not support -C without using -E}}\
 %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
 -undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\
 %{ansi:-trigraphs -$ -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
 %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
 %{traditional-cpp:-traditional} %{trigraphs}\
 %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
 %i %{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |
%{!M:%{!MM:%{!E:cc1plus %{!pipe:%g.ii} %1 %2\
 %{!Q:-quiet} -dumpbase %b.cpp %{d*} %{m*} %{a}\
 %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
 %{traditional} %{v:-version} %{pg:-p} %{p}\
 %{f*} %{+e*} %{aux-info*}\
 %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
 %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}}|
%{!S:as %a %Y\
 %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
 %{!pipe:%g.s} %A }}}}

-----CUT HERE------

Robert
*****************************************************************
* Robert Hoehne, Fakultaet fuer Mathematik, TU-Chemnitz-Zwickau *
* Post:    Am Berg 3, D-09573 Dittmannsdorf                     *
* e-Mail:  Robert DOT Hoehne AT Mathematik DOT TU-Chemnitz DOT DE              *
* WWW:     http://www.tu-chemnitz.de/~rho                       *
*****************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019