This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re:Re: G++ preprocessor problem with unary ## -- summary
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re:Re: G++ preprocessor problem with unary ## -- summary
- From: Fernando Rodriguez Salazar <fernando at elec dot gla dot ac dot uk>
- Date: Fri, 22 Jun 2001 12:34:34 +0100
References: <3.0.6.32.20010319230315.007b5610@mail.cs.ubc.ca>
<3.0.6.32.20010319230315.007b5610@mail.cs.ubc.ca>
<20010320074333.D12047@daikokuya.demon.co.uk>
<3.0.6.32.20010321090201.008456e0@mail.cs.ubc.ca>
>Dave Martindale wrote:- > After doing this, I noticed that the LEDA authors
>must have known about
> the problem already, because the header file which #includes the troublesome
> file has a special check for DECCXX. If that symbol is defined, the outer
> header file includes a pre-expanded version of the troublesome file rather
> than the "normal" one. This says to me that they *knew* the code didn't
> work properly on at least one compiler, but rather than fixing it at the
> source level they built an ugly workaround instead. :-) Someone somewhere
>said it has been fixed upstream; though I have no idea how. Neil.
If you are like me, you are intersted in getting things working as fast as
possible (hey, this is part of my research!). I contacted Algorithmics
Solutions, like it was suggested in this thread, and unfortunately their
answer was "buy the new product, when we release the next version". I'm
sorry but I just can't wait anymore. So here's a quick and dirty kloodge to
get it working. I am using GCC 3.0 on Solaris 2.7, with LEDA R 4.0.
To override the problem with the unary ##, I only fooled the system to
include the patch for the DECCXX. That is, I changed LEDA/event.h to read
something like:
//#if defined (__DECCXX)
#include <LEDA/event_nomacs.h>
//#else
//#include <LEDA/event_macros.h>
//#endif
simple and effective. Once you've done this, you need to recompile the
libraries, or else they will not link with your code. To do this, a few
changes are required in the Makefile (actually in Makefile.src, in the
LEDA/src directory). First make sure g++ is the default compiler and linker.
Next and very important make sure the code compiles with -fPIC, by having the
line:
PIC = -fPIC
(note the capitals). Now this is done, it is time to recompile the
libraries; backup what you want, and then:
cd $LEDA
make del
make
It will compile for a while, and then it will stop with an error relating to
iostream. The opffending file is LEDA/stream.h. In that file, change the
conflicting lines which look something like:
cmd_ostream (char *cmd):ofstream(fileno(popen(cmd,"r")))
to
cmd_ostream (char *cmd):ofstream((const char *) fileno(popen(cmd,"r")))
In my case there were 4 such lines (2 for input stream and 2 for output).
return to the LEDA directory, and again tyupe make. Now, if you are ins
Solaris, another error will appear, complaining about one system header file
with "ISO C++ forbids blah blah blah". Just manually recompile that file
appending the option -fpermisive. You'll need to change into the proper
directory first; I think it is LEDA/src/x11, but I am not completely
possitive.
Afer this is done, return to the LEDA directory, and finally issue the last
Make. It should compile the rest fine.
Now you can compile your code; just two words of warning:
1) Make sure you use g++ to link it. I usually linked with gcc and that
doesn't work anymore, since it doesnt include the c++ library.
2) One of my source files triggers and internal GCC error. I have already
reported the bug. If such a thing happens to you, be sure to report the bug,
and try compiling without oprimization. That worked for me.
Good Luck!
Fernando Rodriguez-Salazar
ACS, University of Glasgow