Porting ANSI C code to C#

T

Tone

I've written a large suite of ANSI C routines for a virtual hand-held
device. A hardware manufacturer with whom we wish to do business
prefers C#.

My understanding of C# is somewhat limited. I see that it is closer to
Java and C++.

What I want to know is this: how difficult would it be to port my ANSI
C code to C#?
 
M

Michael Mair

Tone said:
I've written a large suite of ANSI C routines for a virtual hand-held
device. A hardware manufacturer with whom we wish to do business
prefers C#.

My understanding of C# is somewhat limited. I see that it is closer to
Java and C++.

What I want to know is this: how difficult would it be to port my ANSI
C code to C#?

This is not exactly a C problem, hence offtopic around here.

I would ask in a C# forum -- and ask differently:
- Does C# define interfaces to C (code/libraries)?
- Or: Can I use C library functions from C#?

If yes, you can try to create one or more libraries, define C#
interfaces, wrap certain things into classes, whatever.

I do not know anything about C# but this is the way I would do it.

If said hardware manufacturer wants C# source:
Try to find documents about a common subset and -- more important --
semantic differences for the same syntactic constructions.


Good Luck
Michael
 
C

CBFalconer

Tone said:
I've written a large suite of ANSI C routines for a virtual hand-held
device. A hardware manufacturer with whom we wish to do business
prefers C#.

My understanding of C# is somewhat limited. I see that it is closer to
Java and C++.

What I want to know is this: how difficult would it be to port my ANSI
C code to C#?

Tell him he is mad. All he will be doing is tying himself to
exorbitant Microsoft license fees and exposing himself to the
EULAs. He can save mucho money by avoiding them.
 
M

Mike Wahler

CBFalconer said:
Tell him he is mad. All he will be doing is tying himself to
exorbitant Microsoft license fees and exposing himself to the
EULAs. He can save mucho money by avoiding them.

Ah, the power of marketing. :)

-Mike
 
J

jemmaq99

I've written a large suite of ANSI C routines for a virtual hand-held
device. A hardware manufacturer with whom we wish to do business
prefers C#.

My understanding of C# is somewhat limited. I see that it is closer to
Java and C++.

What I want to know is this: how difficult would it be to port my ANSI
C code to C#?

IMO, C# is more similar to Java than C++.

So a quick answer would be...

Porting your ANSI C code to C# is probably about as difficult
as porting it to Java.

A lot depends on your code. If you're doing scientific
calculations it might be reasonably straight-forward. If you're
moving a lot of typeless data around, casting it to various
types and doing pointer arithmetic, you've got your work cut
out for you.

Keep in mind that you could build a library (ie DLL) of your
C code and call it from C#.

All this is better addressed in microsoft.public.dotnet.general
or microsoft.public.dotnet.language.csharp.

--J.
 
I

Ian Smith

CBFalconer said:
Tell him he is mad. All he will be doing is tying himself to
exorbitant Microsoft license fees and exposing himself to the
EULAs. He can save mucho money by avoiding them.

Unless he is thinking of using mono, dotgnu, or another C#
implementation . . .

Ian.
 
G

Guillaume

Unless he is thinking of using mono, dotgnu, or another C#
implementation . . .

I'm sure that's what he is thinking of...

I really don't see the point of using C# if you're not going
with the Microsoft tools. Doesn't make any sense.

What does seems strange though, is why the heck a *hardware*
manufacturer would want to embrace the C# path. To this day,
nobody even knows whether C# is a viable language in the long
run - that is, nobody except Microsoft itself and their lifelong
ass-kissers. (Sorry for being rude, but that is how I call
businesses which base their whole activity on Microsoft products.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top