Hi there,
I am making a very simple piece of software in C for my final major project for a cultural studies MA. I am exploring software culture and software development methodologies.
The software itself needs to be very simple and to be able to self compile. Because I have little knowledge of C to date, I have choosen the smallest and simplest (non-obfuscated) C compiler I could find.
Details of cc500 plus source code are available here:
CC500: a tiny self-hosting C compiler
There are very simple instructions in order to compile and self-compile the code. They are as follows:
Compilation:
Code:
gcc cc500.c -o cc500_1
Self-compilation:
Code:
./cc500_1 < cc500.c > cc500_2
chmod +x cc500_2
This process works fine but the next step I need to perform is to use cc500_2 to then compile a very simple application that I have created.
I have looked into the cc500.c code and it seems that the only supported functions are:
Code:
void exit(int);
int getchar(void);
void *malloc(int);
int putchar(int);
Therefore I have tried to compile the following application using cc500_2:
Code:
#include <stdio.h>
main(){
int c;
while((c = getchar() != EOF)
putchar(c);
}
I have not been successful with this. A zero KB files is generated. I tried using the gcc to compile the same application and it works ok so I assume the logic is acceptable.
I have also tried removing the #include <stdio.h> line because I'm not sure if this is relevant with the tc500 compiler.
Thanks in advance for any advice.
Gareth