473,221 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

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 1350
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.