468,241 Members | 1,533 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,241 developers. It's quick & easy.

c++ to c

Hello Everyone,
I have a project where I need to write C++ code in C (due to OS
issues). Can someone please show me exactly what I need to do to
convert the code to C.

Thanks
Jami

Here is the code I need to convert to C++:
class CTestSuite : public CTestSuiteBase
{
public :
CTestSuite(CTestBase *aTest);
virtual ~CTestSuite();

virtual TInt InvokeTestL(int argc, char * argv[], TTestConfig *
aConfig) ;

IMPORT_C CTestSuite *GetTestSuite();
virtual int RunTestL(int aArgc, char *aArgv [], TTestConfig
*aConfig);

protected:
CTestBase *iTest;
} ;

class CTestSuiteBase : public CBase
{
public :
virtual TInt InvokeTestL(int aArgc,
char *aArgv [],
TTestConfig *aConfig) = 0;
} ;
class CTestBase : public CBase
{
public :
virtual TInt InitializeL (int argc, char * argv[],
TTestConfig * aConfig) = 0 ;
virtual TInt RunTestL (int argc, char * argv[]) = 0 ;
virtual TInt Cleanup () = 0 ;
} ;

class CBase
{
public:
CBase()
{
}
virtual ~CBase()
{
}
};

Feb 6 '06 #1
13 1225
oops, I mean from C++ to C

Feb 6 '06 #2
jamihuq wrote:
Hello Everyone,
I have a project where I need to write C++ code in C (due to OS
issues). Can someone please show me exactly what I need to do to
convert the code to C.


See this FAQ:

http://www.parashift.com/c++-faq-lit...html#faq-38.13

Cheers! --M

Feb 6 '06 #3
jamihuq wrote:
Hello Everyone,
I have a project where I need to write C++ code in C (due to OS
issues). Can someone please show me exactly what I need to do to
convert the code to C.

You realy need a Cfront compiler, if you can find one.
www.comeaucomputing.com may be a good option.

Otherwise, start from scratch...

--
Ian Collins.
Feb 6 '06 #4
Thanks for the replies. I have already gone to those sites, but I
believe I need to start from scratch. Can someone show me the basic
structure of the code and I think I can take it from there.

Thanks
Jami

Feb 6 '06 #5
jamihuq wrote:
Thanks for the replies. I have already gone to those sites, but I
believe I need to start from scratch. Can someone show me the basic
structure of the code and I think I can take it from there.

Please quote some context.

You should go back to the original requirements and rethink the problem
form a C perspective.

C and C++ are different languages and it's not a good idea to convert
C++ code to C without reevaluating the problem.

--
Ian Collins.
Feb 6 '06 #6
The following article should help:

http://www.eventhelix.com/RealtimeMa...mming_in_c.htm

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based System Design and Object Interaction Modeling
Tool

Feb 7 '06 #7
I have a similar issue on a legacy system with a mix of C++ C and ASm
source.

The Domain 2.1.0 Cfront C++ compiler (runs on the Apollo workstations
does the job you want). Problem is there aren't too many around these
days. The C source it produces isnt too readable but once you get the
syntax you should be fine.

I currently out source this translation work to a sub contractor in the
USA (he isn't free) Our Apollo;'s died some time ago. but I can put
you in touch with him.

On the Comeau side, I recently received a qoute for a cfront
"tailoring" of comeau C++ at $25K USD, as their present compiler does
not do a "to C" translation (even though it uses a CFRONT front end.

Feb 7 '06 #8
In article <11**********************@g47g2000cwa.googlegroups .com>,
jamihuq <ja*********@yahoo.com> wrote:
Hello Everyone,
I have a project where I need to write C++ code in C (due to OS
issues).
What issues does the OS have that prohibits C++?
Can someone please show me exactly what I need to do to
convert the code to C.


Not sure what you're asking. If you have a specific and
very very small code sample (as you provided) that can probably
have some thing said about it, but generally speaking, there is
no simple rules per se that can be spelled out.

On another avenue of approach, we (Comeau Computing) do
port of Comeau C++ to new platforms, however, that depends
among other things on first point above.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Feb 7 '06 #9
In article <11**********************@g43g2000cwa.googlegroups .com>,
Wormald <ia************@yahoo.com.au> wrote:
I have a similar issue on a legacy system with a mix of C++ C and ASm
source.

The Domain 2.1.0 Cfront C++ compiler (runs on the Apollo workstations
does the job you want). Problem is there aren't too many around these
days. The C source it produces isnt too readable but once you get the
syntax you should be fine.

I currently out source this translation work to a sub contractor in the
USA (he isn't free) Our Apollo;'s died some time ago. but I can put
you in touch with him.

On the Comeau side, I recently received a qoute for a cfront
"tailoring" of comeau C++ at $25K USD, as their present compiler does
not do a "to C" translation (even though it uses a CFRONT front end.


Early versions of Comeau C++ were based upon cfront, but that has not
been so for some time (maybe 10 years). Comeau C++ does compile to C,
however, it is normally considered an internal phase of translation
as there is usually nothing of practical use in just the translation
itself, that is, it needs to be useful for a specific platforms,
the front end and tools need to be tailored for a the platform,
it needs accompanying RTL, template instantiation, etc. This is
(well, was) true of cfront itself too.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Feb 7 '06 #10
Thanks to all, but the EventHelix article actually explained exactly
how I needed to implement my classes and virtual functions. Anyone
wanting to know how C implements virtual functions and derived classes
should read this article.
Again, thanks for the great article.

Feb 8 '06 #11
jamihuq wrote:
Thanks to all, but the EventHelix article actually explained exactly
how I needed to implement my classes and virtual functions. Anyone
wanting to know how C implements virtual functions and derived classes
should read this article.
Again, thanks for the great article.


Thanks for your kind words. The following articles might also interest
you:

http://www.eventhelix.com/RealtimeMa...erformance.htm

http://www.eventhelix.com/RealtimeMa...rformance2.htm

These articles describe the mapping with C++ constructs and C.

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based System Design and Object Interaction Modeling
Tool

Feb 9 '06 #12
In article <11**********************@g44g2000cwa.googlegroups .com>,
EventHelix.com <ev********@gmail.com> wrote:
The following article should help:

http://www.eventhelix.com/RealtimeMa...mming_in_c.htm


Unfortunately, the article does not not necessarily discuss
object oriented programming in C. It does reflect some mapping
that is possible, but not necessarily desired even in a C version.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Feb 9 '06 #13
In article <11*********************@g43g2000cwa.googlegroups. com>,
EventHelix.com <ev********@gmail.com> wrote:
jamihuq wrote:
Thanks to all, but the EventHelix article actually explained exactly
how I needed to implement my classes and virtual functions. Anyone
wanting to know how C implements virtual functions and derived classes
should read this article.
Again, thanks for the great article.


Thanks for your kind words. The following articles might also interest
you:

http://www.eventhelix.com/RealtimeMa...erformance.htm

http://www.eventhelix.com/RealtimeMa...rformance2.htm

These articles describe the mapping with C++ constructs and C.


It seems to me out of the dozen or so points brought up in the articles
that 1/2 of them are incomplete and/or mention something erroneous.
But the executive summary, that often the comparison is close, is on
the money, which is often contrary to ESP et al mantra.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Feb 9 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.