Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » howto set U++ to comple for non-c++ source?
howto set U++ to comple for non-c++ source? [message #9340] Sat, 28 April 2007 15:23 Go to next message
ebojd is currently offline  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 Wink 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?

EBo --
Re: howto set U++ to comple for non-c++ source? [message #9342 is a reply to message #9340] Sat, 28 April 2007 17:20 Go to previous messageGo to next message
ebojd is currently offline  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.

EBo --
Re: howto set U++ to comple for non-c++ source? [message #9383 is a reply to message #9342] Thu, 03 May 2007 17:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
In fact, if it has .c extensions, it should compile as it is (as C, not C++).

Mirek
Re: howto set U++ to comple for non-c++ source? [message #9385 is a reply to message #9383] Thu, 03 May 2007 17:38 Go to previous messageGo to next message
ebojd is currently offline  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.

EBo --
Re: howto set U++ to comple for non-c++ source? [message #9389 is a reply to message #9385] Fri, 04 May 2007 07:00 Go to previous message
ebojd is currently offline  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.

EBo --

[Updated on: Fri, 04 May 2007 07:04]

Report message to a moderator

Previous Topic: pre-define for preprocessor
Next Topic: howto clean up generated test data?
Goto Forum:
  


Current Time: Tue Apr 23 10:58:44 CEST 2024

Total time taken to generate the page: 0.02543 seconds