# Example to show basic usage. # The first version calls the main function with the run state # while the second version does the same with the memory state # by symbol resolution with some additional access tests. # A third version (commented out) shows how to write an executable. from __future__ import print_function from tinycc import TinyCC from ctypes import (CFUNCTYPE, c_int, c_void_p, Structure, c_ubyte, POINTER, c_char, create_string_buffer, cast) C_CODE = ''' #include /* a struct with some bytes and a length */ typedef struct Test { int length; unsigned char *bytes; } Test; /* some globals */ #ifdef STANDALONE Test test = {10, "standalone"}; #else Test test = {26, "abcdefghijklmnopqrstuvwxyz"}; #endif int value = 12345; int main(int argc, char **argv) { int i; char **pos = argv; printf("Hello Python world from C!\n"); /* list arguments */ for (i=0; i