c compiler for windows code example

Example 1: install c compiler windows

Step 1) Go to http://www.codeblocks.org/downloads and click Binary Release.
Step 2) Choose the installer with GCC Compiler, e.g., codeblocks-17.12mingw-setup.exe
which includes MinGW's GNU GCC compiler and GNU GDB debugger with Code::Blocks source files.
Step 3) Run the downloaded installer and accept the default options.
Step 4) Accept the Agreement
Step 5) Keep the component selection default and click Next.
Step 6) You may change the installation folder and click Next.
Step 7) To launch Code::Blocks double click on the icon.
Step 8) It will detect the gcc compiler automatically, set it as default.
Step 9) You will see the IDE Home screen.

Example 2: how do i make my own c compiler

To make your own c compiler:
	* First start with the lexer/tokenizer, it should turn code to tokens like this:
	int main(){return 2;} => INT, SPACE_SEPARATOR, {IDENTIFIER, "main"}, OPENING_BRACE, RETURN_KEYWORD, {LITERAL, "2"}, CLOSING_BRACE
	to do this make a list of tokens and translate code to tokens (i wrote all c tokens for my own c compiler)
	* Second make a Parser:
	it will turn tokens to an AST tree
    you will use it to compile,
    it ressembles this:
    	main.cpp << not important
        	|
            main_entry: {name: "main", type: "function", return_type: "int"}
        	|
           /
		  {return, type: "keyword"}
		   |
		return value: {literal: "2", type: "int"}
	* And third make an x86 code writer
    it should translate the tree to x86
	the result for our code in x86 is:
	    .globl _main
        _main:
            movl    $2 %eax
            ret
PS: i am not giving code so you can write your c compiler in any language, and also make you actually feel like you wrote it yourself instead of copy pasting