Hello,
I am trying to get the intertwining spiral example from libGE (a grammatical evolution library) compiled and running with tinycc and I come up with 2 errors at compile time.
error C2440: '=' : cannot convert from 'void *' to 'int (__cdecl *)(int)'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
error C2440: '=' : cannot convert from 'void *' to 'int (__cdecl *)(int)'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Here is what I believe to be the relevant code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
/* create tcc state */
TCCState *s;
int (*func)(int);
int (*fitnessfunc) (int);
void *mem;
int size;
s = tcc_new();
if (!s)
{
fprintf(stderr, "Could not create tcc state\n");
exit(1);
}
tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
/* add the math library */
tcc_add_library(s, "m");
/* Compile the GE functions in the tcc state */
if (tcc_compile_string(s, GEfunc) != 0) {
fprintf(stderr,
"Error in GEspiral.c TCC string compilation!, Exiting!\n");
exit(-1);
}
string buffer;
//Write start code to buffer
buffer = ISstart;
//Write phenotype code to buffer
buffer += phenotype->getString();
//Write end code to buffer
buffer += ISend;
// Compile the buffer.
if (tcc_compile_string(s, buffer.c_str()) != 0) {
fprintf(stderr, "Error in phenotype TCC compilation!, Exiting!\n");
exit(-1);
}
size = tcc_relocate(s, NULL);
if (size == -1)
return 1;
mem = malloc(size);
if (tcc_relocate(s, mem) != 0) {
fprintf(stderr, "Error tcc_relocate failed, Exiting!\n");
exit(-1);
}
// Get pointer to the main function symbol.
func = tcc_get_symbol(s, "main");
if (!func) {
fprintf(stderr, "Error: could not tcc_get_symbol main, Exiting");
exit(-1);
}
// Execute the main function.
func(32);
// Get the fitness function symbol.
fitnessfunc = tcc_get_symbol(s, "AssignFitness");
|
The errors are specific to the lines:
1 2 3
|
func = tcc_get_symbol(s, "main");
// and
fitnessfunc = tcc_get_symbol(s, "AssignFitness");
|
I am compiling on Windows Vista with MS Visual Studio 2008.
I am using a modified GAlib 2.4.7
http://lancet.mit.edu/ga/
an unmodified libGE 0.26
http://bds.ul.ie/libGE/
and Tiny C Compiler 0.9.25
http://bellard.org/tcc/
If you require any further information or code please ask, I am happy to provide.
P.S. If I comment out the relevant parts of the code I get no further compile errors, but I do get several linker errors.