473,408 Members | 1,907 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,408 software developers and data experts.

translating oo features to C

I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,

David
Jan 31 '08 #1
6 1336
dv*******@gmail.com wrote:
I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,
An early C++ "compiler" perhaps?

As I understand it, C++ was initially precompiled to C source.
Jan 31 '08 #2
Mark Bluemel wrote:
dv*******@gmail.com wrote:
>I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,

An early C++ "compiler" perhaps?

As I understand it, C++ was initially precompiled to C source.
'cfront' might be what you're looking for, although I guess the generatted
code would be pretty illegibel to humans.

Bye, Jojo
Jan 31 '08 #3
ppi
On Jan 31, 11:32 am, Mark Bluemel <mark_blue...@pobox.comwrote:
dvangu...@gmail.com wrote:
I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,

An early C++ "compiler" perhaps?

As I understand it, C++ was initially precompiled to C source.
yep cfront did it (the original compiler for AT&T). I think comeau c++
compiler still does that: from C++ sources it generates C code
http://www.comeaucomputing.com/.
Jan 31 '08 #4
On Jan 31, 8:20*am, dvangu...@gmail.com wrote:
I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,
Here you go:
http://www.softwarepreservation.org/.../release_3.0.3

Don't imagine that reading the C output will be enjoyable.
Jan 31 '08 #5
dv*******@gmail.com wrote:
>I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,
Check the Portable Object Compiler for an Objective-C to C translator:

http://users.pandora.be/stes/compiler.html
Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Jan 31 '08 #6
"Tomás Ó hÉilidhe" <to*@lavabit.comwrote in message
news:Xn**************************@194.125.133.14.. .
:
>I was wondering if there are any open source compilers out there to
translate the C++/Java/C#-like object model to C. Thanks,

David


Hidden pointers is what OO is all about for the most part.

The following in C++:
[...]
>
is implemented as:

typedef struct VTable_Circle {
double (*GetArea)(Circle*);
} VTable_Circle;

typedef struct Circle {
VTable_Circle const *vtable;

double radius;
} Circle;

double GetArea(Circle *const this)
{
return 3.14 * this->radius * this->radius;
}

VTable_Circle vtable_circle = { GetArea };

void ConstructCircle(Circle *const p)
{
p->vtable = vtable_circle;
}
FWIW, you can use some macros to implement the interface so you don't have
to write code like:
Circle c;
ConstructCircle(&c);
c.vtable->GetArea(&c);


Something like:

#define Circle_GetArea(mp_this) ( \
(mp_this)->vtable->GetArea((mp_this)) \
)


Now you can do:

Circle c;
ConstructCircle(&c);
Circle_GetArea(&c);


Also, if you pick some standard function names in the vtable, you could do
some abstract interface stuff... Something like:
typedef struct VTable_Circle {
void (*Object_Destroy) (Circle*);
double (*GetArea)(Circle*);
} VTable_Circle;
#define Object_Destroy(mp_this) ( \
(mp_this)->vtable->Object_Destroy((mp_this)) \
)

and write:

Circle c;
ConstructCircle(&c);
Circle_GetArea(&c);
Object_Destroy(&c);

The Object_Destroy function will work for any object which follows the
"standard" vtable naming convention.

Here is a more complete example:

http://groups.google.com/group/comp....106926ba5db19f


IMHO, it makes things "cleaner"... And in some respects, I like it better
than C++...

;^)


Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Davis Marques | last post by:
hi; I'm translating some PHP scripts to Python and have hit a roadblock with a for statement. If someone could explain to me how one should translate the multiple increment, evaluations, etc....
2
by: Henrik S. Hansen | last post by:
How do you best go about translating characters like '\\n' to '\n'? This is for a configuration file parser, where the "backslash convention" is supported. The naive approach --...
2
by: Roderick Bloem | last post by:
I am going to take the liberty of crossposting this to comp.lang.c++ (originally comp.lang.c), and to summarize the discussion for the sake of those reading only c++. The question is: If you are...
8
by: gregf | last post by:
Is there a way or a program (for windows) that can translate foreign characters inot the proper html code? I have a word document with many different characters and I really don't want to spend all...
23
by: gregf | last post by:
I have a paragraph of text pasted into a word document, it's in Polish, complete with polish characters. They show up just fine in word, but the program I use for web page programming, HomeSite,...
11
by: Alberto Giménez | last post by:
Hi, I've seen some object oriented programming bits out there and i'm not sure if they're legal. For example: struct Object { int field1; int field2; }; struct SubObject { int field1; /*...
1
by: J | last post by:
Hi all, I just finished a asp.net project, which is based on English language, and all of sudden, client need different language also, say German, Chinese, etc. So, what is the best way, or I...
1
by: timn | last post by:
Translating Access SQL queries into SQL subqueries. -------------------------------------------------------------------------------- I have a query in Access that uses a subquery, I would like...
2
by: vj | last post by:
I have a perl script which connect to network stream using sockets. The scripts first logins in to the server and then parses the data comming from the socket. Statement 1: my $today =...
5
by: Andrus | last post by:
I have database containing translations. I'm creating VS 2005 WinForms application which should use this database to translate menu items to user language. I replaced lines in myform.designer.cs...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.