tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] How to get var and its type by executed c-string ?


From: Dmitrij K
Subject: [Tinycc-devel] How to get var and its type by executed c-string ?
Date: Sat, 19 Oct 2013 23:19:14 +0000

Hi all.

How can I get type of a var in the runtime ?

code:

[CODE=C]

#include "libtcc.h"

const char *my_program =
"extern int myint;\n"
"\n"
"myint=0;\n"
"\n"
"int main(int argc, char ** argv){\n"
"myint=77;\n"
"return 0;\n"
"}\n";


int main(int argc, char ** argv){

TCCState *s;

s = tcc_new();
if (!s) {
fprintf(stderr, "Could not create tcc state\n");
exit(1);
}

tcc_set_lib_path(s, "../");
tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
if (tcc_compile_string(s, my_program) == -1)
        return 1;
tcc_run(s, argc, argv);


// HERE is I can not to know what is the type of a var (for example is the myint now)
// but I need it for sprintf into a buffer (for return the buffer in the cstring mode for other things)


tcc_delete(s);

return 0;
}
[/CODE]

--
Have a nice day.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]