Co to C# converter?

  • Thread starter Thread starter Jon Gabel
  • Start date Start date
J

Jon Gabel

I want to use C code libraries within a C# application. Besides
creating a separate DLL for the C code and calling the DLL from the C#
app, is there any kind of converter out there for creating C# code
out of C code?

Regards,

Jon G
 
You may be able to compile your C code in a Visual Studio.NET C++ project
with the /CLR switch and it will be compiled into a .NET managed assembly.
Peter
 
Hello Jon,

I don't think that u find any kind of C to C# convertors.
Languages are too different as in syntas as in design. There is nothing to
convert.

JG> I want to use C code libraries within a C# application. Besides
JG> creating a separate DLL for the C code and calling the DLL from the
JG> C# app, is there any kind of converter out there for creating C#
JG> code out of C code?
JG>
JG> Regards,
JG>
JG> Jon G
JG>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Peter Bromberg said:
You may be able to compile your C code in a Visual Studio.NET C++ project
with the /CLR switch and it will be compiled into a .NET managed assembly.

This can be a viable route, but it depends on the code. VC++ can compile
C++ to managed code, but not C, so the first step would be to get the C
code to compile as C++. To make it accessible to C#, you'd then probably
have to wrap the C-style API into a class-based API, since C# has no concept
of a free function.

In the end, you'll still end up with a separate DLL since you can't mix C++
and C# in a single DLL. (Actually, I think you can, but it's not for the
faint of heart). In that case, the best option may be to simply compile the
C code into a DLL and use P/Invoke to call it from C# and skip the
conversion to managed C++.

Which is best depends a great deal on the nature of the C code in question.

-cd
 
Michael said:
I don't think that u find any kind of C to C# convertors.
Languages are too different as in syntas as in design. There is nothing
to convert.

There has been created language translators between almost
all languages, so of course it can be done.

The language itself should not be that bad - espcially
not if unsafe C# were allowed.

The C RTL would require some work though.

The only thing available seems to be
http://code2code.net/ though.

Something else is: what is the point ? The converted
code would not look like human written C# code, so
it would not be worth much.

Arne
 
Hello Arne_Vajhøj,

OP want to convert C to C#, it's not the same AS C++ to C#
C doesn't have classes, virtual function, exception handling and etc.
Convertion doesn't help u here, code need to be redisigned


A> Michael Nemtsev wrote:
A>A> There has been created language translators between almost all
A> languages, so of course it can be done.
A>
A> The language itself should not be that bad - espcially not if unsafe
A> C# were allowed.
A>
A> The C RTL would require some work though.
A>
A> The only thing available seems to be
A> http://code2code.net/ though.
A> Something else is: what is the point ? The converted code would not
A> look like human written C# code, so it would not be worth much.
A>
A> Arne
A>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
A> There has been created language translators between almost all
A> languages, so of course it can be done.
A> A> The language itself should not be that bad - espcially not if unsafe
A> C# were allowed.
A> A> The C RTL would require some work though.
A> A> The only thing available seems to be
A> http://code2code.net/ though.
OP want to convert C to C#, it's not the same AS C++ to C#
C doesn't have classes, virtual function, exception handling and etc.

That argument is completely bogus.

What features C++ has that C does not have no impact what
so ever on whether a C++ to C# convert can be used
for converting from C to C#.

What matters is what features C has that C++ does
not have.

And that is rather limited.
Convertion doesn't help u here, code need to be redisigned

Not necessarily.

Arne
 

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

Back
Top