History

tcc -E -P10 : output all numbers as decimals

This may be used to preprocess Fabrice Bellards initial revision in this repository to demonstrate its capability to compile and run itself (on i386 32-bit linux or windows). Initial revision: 27f6e16bae9d0f73acec07f61aea696ab5adc680 Also needed: * an empty stdio.h * a wrapper named tc.c with void expr(void); void decl(int); void next(void); #include "tcc.c" * an hello.c such as int main() { printf("Hello World\n"); return 0; } All files with unix LF only lines. Then ... * preprocess the source $ tcc -E -P10 -I. tcc.c -o tc1.c * compile the compiler $ tcc -w -I. tc.c -o tc -ldl * run it to compile and run itself to compile and run itself to compile and run itself to compile and run hello.c $ ./tc tc1.c tc1.c tc1.c hello.c --> Hello World! ------------------------------------------------------ * On i386 windows this may be added to the tc.c wrapper #ifdef _WIN32 #include <windows.h> void *dlsym(int x, const char *func) { if (0 == strcmp(func, "dlsym")) return &dlsym; return GetProcAddress(LoadLibrary("msvcrt"), func); } #endif

grischka committed 10 years ago

Commit 5e4d0711 parent a66ba1f1 file · +6 −0Browse files

Unified · Split

tccpp.c+6−0
@@ -3711,6 +3711,12 @@ ST_FUNC int tcc_preprocess(TCCState *s1) · 3710 unmodified lines
3711 ;3711 ;
3712 define_start = define_stack;3712 define_start = define_stack;
3713 3713
3714 /* Credits to Fabrice Bellard's initial revision to demonstrate its
3715 capability to compile and run itself, provided all numbers are
3716 given as decimals. tcc -E -P10 will do. */
3717 if (s1->Pflag == 1 + 10)
3718 parse_flags |= PARSE_FLAG_TOK_NUM, s1->Pflag = 1;
3719
3714#ifdef PP_BENCH3720#ifdef PP_BENCH
3715 /* for PP benchmarks */3721 /* for PP benchmarks */
3716 do next(); while (tok != TOK_EOF); return 0;3722 do next(); while (tok != TOK_EOF); return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t