I am using visual studio 2013 with the visual studio 2010 compiler.
I am re-using some c code in my c++/CLI project and I am getting compile errors. All of the files are in the same project and all of the body files are not using pre-compiled headers
I am trying not to edit the re-used code, if possible...
Here is a sample of the code, note libFunc.h and .c are the re-used code and I am writing wrapper.cpp:
// libFunc.h
typedef struct
{
double max;
double var;
} myStruct;
void libFunc(char * filename, myStruct *(*arg)[]);
void readVals(char * filename, myStruct *(*arg)[]);
void assignVals(myStruct *arg, char vals[][1024]);
// libFunc.c
void libFunc(char * filename, myStruct *(*arg)[])
{
readVals(filename, arg);
}
void readVals(char * filename, myStruct *(*arg)[])
{
char vals[15][1024];
char *line = (char *) malloc(1024);
s = fopen(filename, "r");
while(fgets(line, 1024, s) != NULL)
{
// parse tokens into vals
assignVals((*arg)[index], vals);
}
}
void assignVals(myStruct *arg, char vals[][1024])
{
arg->max = atof(values[0]);
arg->var = atof(values[1]);
}
// wrapper.cpp
#include "libFunc.h"
int wrapper()
{
myStruct *myVar[1];
char filename[512];
strcpy(filename, "input.txt");
libFunc(filename, &myVar);
}
I get the error:
cannot convert myStruct *(*)[1] to myStruct *(*)[].
I tried:
myStruct ** myVar = new myStruct*[1];
libFunc(&myVar);
This resulted in the error:
cannot convert myStruct *** to myStruct *(*)[].
How do I pass in something that it will accept?
The code does not have to be compiled as c++
Any solution to this issue must work in Visual Studio 2013 with Visual Studio 2010 compiler, and by "work" I mean that "Build Solution" has to build everything including these c files.