delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/14/18:24:26

From: Robert Hoehne <Robert DOT Hoehne AT Mathematik DOT tu-chemnitz DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Configuring RHIDE to use .cpp files
Date: Tue, 14 Jan 1997 11:11:07 +0100
Organization: TU Chemnitz-Zwickau
Lines: 86
Message-ID: <32DB5BBB.23FD@Mathematik.tu-chemnitz.de>
NNTP-Posting-Host: env.hrz.tu-chemnitz.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi all users of RHIDE,

As I saw some posts in the last days about the use of
.cpp files with RHIDE and some people thought that this
is a bug of RHIDE I will say something about this here.

At first: This is NOT a bug of RHIDE. It is a bug of gcc
which emits the wrong filename to the assembler when
compiling a .cpp file. 

In the FAQ section 12.6 is expalined, how you can solve
this when compiling from commandline. Within RHIDE it is
also possible. I append below a prewritten post, which
shows also how to use the features of RHIDE to overwrite
mostly every thing by setting some environment variables.


To show, how powerfull the behaviour of RHIDE can be changed, I will
give here a sample of overwriting the builtin rules for compiling
to surround the gcc bug dealing with source files which have the
suffix '.cpp'.

If you add the following lines to your djgpp.env, you can now also
debug programs which has source files with the suffix '.cpp'.
------ cut here --------
[rhide]
RHIDE_TEMP_SOURCE=$(TMPDIR)/$(notdir $(SOURCE_NAME))
RHIDE_TEMP.CPP=$(subst -o $(OUTFILE),-E -o
$(RHIDE_TEMP_SOURCE),$(RHIDE_COMPILE_CC))
RHIDE_TEMP.CXX=$(subst -c $(SOURCE_NAME),-x c++-cpp-output -c
$(RHIDE_TEMP_SOURCE),$(RHIDE_COMPILE_CC))
RHIDE_TEMP.RM=rm -f $(RHIDE_TEMP_SOURCE)
RHIDE_COMPILE.cpp.o=$(RHIDE_TEMP.CPP); $(RHIDE_TEMP.CXX);
$(RHIDE_TEMP.RM)

------ cut here ---------

Description of the above lines:
Theoretically all the above can be put in one single line but for a
better
reading I have splitted them.

At first I create a temporary filename in the temp directory, which is
setup by RHIDE at startup.

The second line calls gcc with the '-E' switch to do only preprocessing
and redirect the output to the temporary filename.

The third line now compiles that temporary file with the '-x
c++-cpp-output'
switch to tell gcc, that the file was already run trough cpp which has
the
good side effect, that gcc does not emit the '-dumpbase' switch to
cc1plus.

The fourth line then removes the temporary file.

And the fifth line merges them all together to make now the real
command,
which is executed when RHIDE compiles a file with the suffix '.cpp' to
a file with the suffix '.o'.

To show the result of the above, here a short example:

Normally RHIDE compiles a .cpp file with the command:

gcc -c foo.cpp -o foo.o

and now (with the above trick) it compiles with:

gcc -c foo.cpp -E -o c:/tmp/RHaaaaaa/foo.cpp; gcc -c
c:/tmp/RHaaaaaa/foo.cpp -o foo.o; rm -f c:/tmp/RHaaaaaa/foo.cpp

(The directory c:/tmp/RHaaaaaa may be different on your system)
As you can see this uses also the very powerfull feature of DJGPP's
system(), which allows multiple commands in on line.


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