Hi,
I do not know how to code in C-Sharp. I want to add a C function to an existing, working C-Sharp program, and compile it. Let's say the C function is something like this:
Test_Function ( )
{
/* C codes go here. */
}
What do I need to do to make this C-Sharp program compile with the above test C function added? I tried adding standard C libraries at the top of the C-Sharp program, but it won't compile.
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
Please help. Thank you.
how to compile C function inside C-Sharp program?
Started by serendipity1276, Nov 05 2011 06:48 PM
3 replies to this topic
#1
Posted 05 November 2011 - 06:48 PM
|
|
|
#2
Posted 05 November 2011 - 09:05 PM
What your wanting to do is write and run C code in a C# IDE? As far as I know that just plain won't work. You can convert the C code into C# code then add it, but just plain using C code won't work. Post your C code and we can help convert possibly.
EDIT: You may perhaps be able to put the C code in a file and use C# to call a program to compile it.
~ Committed.
EDIT: You may perhaps be able to put the C code in a file and use C# to call a program to compile it.
~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#3
Posted 06 November 2011 - 05:52 PM
I think it would be easier to just recode it into c#. If you know C then the transistion should be easy, depending on the contents of the actual function that is. Could you import the C code into a UML editor and then use the editor to export into C# code? I've never tried, but it may be possible.
#4
Posted 25 November 2011 - 01:34 AM
If you want to keep you code in C then you will have to keep it in a separate DLL. And call the DLL function by C# using PInvoke
----------------------
U Zafar
SE
Retail POS Software - TradeMeters™ is a Reliable Point of Sale Software Solution POS software
----------------------
U Zafar
SE
Retail POS Software - TradeMeters™ is a Reliable Point of Sale Software Solution POS software
Edited by TradeM, 29 November 2011 - 12:51 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









