Vikyboss
Vikyboss

Reputation: 960

Porting C code to C#

As a part of my work, I have to port parts of firmware written in c to a gui software that is written in c#. So, I have to convert the c code to c#. I could have used the c code as it is and call it from the gui, but people in here decided to port instead of using c file as it is.

When I was going to through the code, I found something like this:

static xdata x y;

Then after some research found that xdata says the chip to store this variable in a external memory. Now the problem is how can I write that line in c#.

Thanks everyone and this wonderful community.

Upvotes: 2

Views: 2292

Answers (3)

Tod
Tod

Reputation: 8242

Your question leaves out a lot of details. When I see "I have to port parts of firmware written in c to a gui software that is written in c#.", I would assume the "parts" being ported are not hardware related. However, maybe that is not the case and you are using something like the .NET Micro Framework. Are you going to be running the C# code on some form of embedded CLR, or is strictly going to run on a PC? If it's just going to run on a full Windows .NET platform. If the latter then you can ignore the xdata qualifier since C# has no analog to it.

Upvotes: 2

semaj
semaj

Reputation: 1575

Consider porting your C code to a .NET C++ dll instead of C#. This should minimize your porting problems. The xdata keyword can be effectively remove by an empty macro.

Use something like the following in a header file in your C++ project:

#define xdata

The .NET C++ dll can easily be referenced by the C# GUI project.

Upvotes: 2

Vinicius Kamakura
Vinicius Kamakura

Reputation: 7778

Just remove it. xdata just a tip for the compiler to where to store the variable. If you remove it the C# compiler will figure it out on it own.

Upvotes: 3

Related Questions