Original Post
I am using the tinycc mini compiler for generating dynamic code for a small project. The problem is that for a reason i can't pass FLOATS to functions, which are inside the main program. But if I change it to double it works. For a reason the literal 3.1416 is not interpreted as a float literal. I am using visual studio 2008 for compiling this code.
This is my code.
[Edited by - becoolnike on December 15, 2010 11:25:38 PM]
This is my code.
#include <iostream>#include "libtcc.h"using namespace std;void local( float f ){printf ( "%f \n", f );}void main(){TCCState *s;void (*main)();void *mem;int size=0;// This is our code. For a reason the literal 3.1416 is not intrepeted// as a float.char code[] = " void main () { local( 3.1416 ); }" ;s = tcc_new();if (!s)cout << "Error" << endl;/* MUST BE CALLED before any compilation */tcc_set_output_type(s, TCC_OUTPUT_MEMORY);if ( tcc_compile_string(s, code) == -1)cout << "Error" << endl;tcc_add_symbol(s, "printf", printf);tcc_add_symbol(s, "local", local);size = tcc_relocate(s, NULL);if (size == -1)cout << "Error" << endl;mem = malloc(size);tcc_relocate(s, mem);main =( void (*) (void) ) tcc_get_symbol(s, "main");if (!main)cout << "Error" << endl;// call the main functionmain();system ( "pause" );}[Edited by - becoolnike on December 15, 2010 11:25:38 PM]