473,395 Members | 1,468 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,395 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 1353
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.