I need to be able to call some very old C functions from a form application. What I found on line was to use 'extern "C"' to let Visual Studio know how to handle the calling parameters. But I'm getting a compiler error and not sure where it is coming from.
I changed the Form1.h file as:
extern "C" char *doit();
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
// richTextBox1->Text="Button Hit\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7";
richTextBox1 = doit();
}
private: System::Void richTextBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
and the actual doit.c file as:
#include <stdio.h>
char *xyz = 0;
extern "C" char *doit()
{
xyz = calloc(1, 1024);
sprintf(xyz,"Button Hit\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7");
return xyz;
}
The error I'm getting is:
Command line error D8045: cannot compile C file '.\doit.c' with the /clr option File cl
Can this even be done?
If so, can someone point me to an example.
Thanks