A (non-uninstressting) quine that works both in C and Python
The most intressting trick here use is how I managed to make the ":" work in C: using a #define pp(a) pp(char* a){int i=1?1
that doesn't get parsed in python, you can collapse the ":" as the end of a ternary operator!
#include < stdio.h> // This program is both a quine in python and C.
#include < stdlib.h> // And it is non-trivial, they share every function's code.
#define def void
#define pass }
#define replace(a,b,c) replace(char* a, char b, char c){ int i=1?1
#define pp(a) pp(char* a){int i=1?1
#define print_str(a) print_str(char* a){ int i=1?1
#define main(_) main(){ char* text;int i=1?1
#define NEWINT(var) (int var)
#define bool(cond) (cond){ int _=1?1
#define tt char overall[]
#define chr(x) (x)
#define len(x) (txt[i]==0?0:99999)
#define list(x) overall
tt = "#include < stdio.h> // This program is both a quine in python and C.$#include < stdlib.h> // And it is non-trivial, they share every function's code.$$#define def void$$#define pass }$#define replace(a,b,c) replace(char* a, char b, char c){ int i=1?1$#define pp(a) pp(char* a){int i=1?1$#define print_str(a) print_str(char* a){ int i=1?1$#define main(_) main(){ char* text;int i=1?1$#define NEWINT(var) (int var)$#define bool(cond) (cond){ int _=1?1$#define tt char overall[]$#define chr(x) (x)$#define len(x) (txt[i]==0?0:99999)$#define list(x) overall$tt = @&@;$$def replace(txt, a, b):$ 1;$ i = 0;$ while bool(i < len(txt)):$ 1;$ if bool(txt[i] == chr(a)):$ 1;$ txt[i] = chr(b);$ pass;$ i = i + 1;$ pass;$pass;$$#undef replace$$def print_str(txt):$ 1;$ i = 0;$ while bool(i < len(txt)):$ 1;$ putchar(txt[i]);$ i = i + 1;$ pass$ return;$pass$$#undef print_str$$def pp(txt):$ 1;$ i = 0;$ while bool(i < len(txt)):$ 1;$ if bool(txt[i] != chr(38)):$ 1;$ putchar(txt[i]);$ pass$ if bool(txt[i] == chr(38)):$ 1;$ replace(txt,10,36);$ replace(txt,34,64);$ print_str(txt);$ replace(txt,36,10);$ replace(txt,64,34);$ pass$ i = i + 1;$ pass$pass$$#undef pp$$def main():$ 1;$$ text = list(tt);$$ replace(text,36,10);$ replace(text,64,34);$ pp(text);$ return 0;$pass$$#define idk 4 /*$putchar = lambda x: print(x,end='') # Oui ici j'en ai eu marre. On se le permet alors.$main()$#*/$";
def replace(txt, a, b):
1;
i = 0;
while bool(i < len(txt)):
1;
if bool(txt[i] == chr(a)):
1;
txt[i] = chr(b);
pass;
i = i + 1;
pass;
pass;
#undef replace
def print_str(txt):
1;
i = 0;
while bool(i < len(txt)):
1;
putchar(txt[i]);
i = i + 1;
pass
return;
pass
#undef print_str
def pp(txt):
1;
i = 0;
while bool(i < len(txt)):
1;
if bool(txt[i] != chr(38)):
1;
putchar(txt[i]);
pass
if bool(txt[i] == chr(38)):
1;
replace(txt,10,36);
replace(txt,34,64);
print_str(txt);
replace(txt,36,10);
replace(txt,64,34);
pass
i = i + 1;
pass
pass
#undef pp
def main():
1;
text = list(tt);
replace(text,36,10);
replace(text,64,34);
pp(text);
return 0;
pass
#define idk 4 /*
putchar = lambda x: print(x,end='') # Oui ici j'en ai eu marre. On se le permet alors.
main()
#*/