ebojd Messages: 225 Registered: January 2007 Location: USA
Experienced Member
I have an external library that compiles with gcc but not g++. The issues is the way the original code was written that uses "this" and other c++ keywords...
Instead of trying to port some 50,000 lines of C code to C++, is there an easy way to set up U++ to compile a source base with ansi C? (I just had an idea, but I'll post just in case I'm wrong, and besides it might give someone else an idea The thought that just crossed my mind is to set a compiler specific command like "-x c --ansi" for the GNU compilers. Can you see anything seriously wrong with doing this?
ebojd Messages: 225 Registered: January 2007 Location: USA
Experienced Member
For those who might be interested it was actually easy. I set a compiler flag "GCC: -x c " and then simply defined an external wrapper around my entry point:
extern "C" {
int old_main (int argc, char *argv[]);
};
and it worked like a charm.
The only real problem I can see is that the package depends on GD, PNG, PDF, fontconfig, and a few others. I cannot compile the plugin/*'s for these because I have to compile them with a C not C++ compiler.
ebojd Messages: 225 Registered: January 2007 Location: USA
Experienced Member
I'll try it again now that I know that I have it working with the "-x c" compiler switch, but when I first started poking at this both g++ and MinGW used C++, and there are a couple of files that have #ifdefine _cplusplus sections in them. The compielr was spewing all over the place. Forcing it to default to the C parser worked.
ebojd Messages: 225 Registered: January 2007 Location: USA
Experienced Member
Well, it appears I was wrong and the problem was something else. Sorry to waste the bandwidth... Once I got the mysterious problem solved I no longer need the "-x c" forcing C vs C++ parser.