compile c program code

gcc -shared -o libhello.so -fPIC hello.c

4
2

                                    # Compile Code
gcc filename.c
# Run code
.\a.exe

4 (2 Votes)
0
0
0

                                    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

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
compile c program online run c code online c comiler online compiler c language dev c online compiler best compiler for c windows 10 online comipler c programize c compiler run program compiler c control f run c program gcc compile c program cli top compiler for c language dev c compiler c compiler programmiz compile c to gcode c editor and compiler online c compoiler how C compiles code how to change the c compiler from c99 to c89 c compiler online c compiler example c editor and compiler for windows 10 what is the official c compiler compile -c in c compile to c languages how to compile another c program in c "c" compiler what is the best c compilers best compilers for c ONLINE C COPILER c language online c programming online latest c compiler online c program install c complier how to compile c using make c program compiler download compiler process in c c complier compile and run a .c file c compiler source code in c c compiler programiz online c complier make c compiler for isa Types of compiler in C c compiler on windows c compliler online c comapiler how to run a code in c compiler programming in c language c editor code What is best compiler for C programmiz c compiler c file compiler How to compile a C program from another C program how to compile a C program using a C program code that compiles into c compile c program "cl" compile c program cl c compilers gcc compile c program how is the c compiler written in c compile and run c code turbo c directly run program online compiler for c program best online compiler for c how to complie and run in c onlinec c compilrer c programming language online editor compiler online c c program compiler c programing online\ official compiler of c language c code compile and run c compiled code? compile and run c file onlinre c compiler download c compliler step by step c compiler c online compiller code compiler c how to run and compile c program compiler c online compile and execute c file how to compile a program in c onlline c complier c compliler how to run ode of c language c ompiler for windows c compiler works c compiler working coding in c online is c compiler written in machine code c compiler app online c comlier compiler c download compiler in c download c programming comiler c ompiler online c compilers run c online program c online how make a c compiler compiler for c create beginner compiler c code examp best online c compiler c code compiler online how to automatically compile and run a c program in c compiler c language turbo c compiler compile c online how to compile a file in c compiler for c c programming online compiler how to run c code run c program online c code compiler how to run a compiled c program online C programming online compiler for c writing a c compiler c online compailer compile c program for windows how to compile with -I c online c compiler programiz programiz c online compiler write c code online c code run online compiler for c language the C compiler compile the code line by line correct or not online c compilet online c compiler gcc console to compile c code how does a c compiler work hwo to compile c file compiler c windows compiler c online free execute c program online compile c programs c editor and compiler online c program compiler programiz.com c compiler how does compiler works in c compilador c online c compiler for windows 10 compile c program code c compiler source code What compiler could you use to compile a C code? how to compile c code in windows best online compiler for c language c language compiler for windows 10 run a c program online C compiler. c program online compiler online c compoiler c language online compiler c compiler windows online c compile windows c compiler best compiler for c language c code compiler compiler c c compiler for windows compile a program in c how to run c program c program to run a c program c compiler online c online comipler programiz c compiler c compile online c compiler how do i make my own c compiler how to compile c files on windows start and compile c program compile c code platforms how to compile c code in c how to compile c code for web How ti compile C code how to compile c== code hwo to compile c code where to find c compile code how to compile c code on windows what happens when you compile a program in c compile c program how to compile c program in windows can c compile itself compile program in c how to compile and run a program in c c compile script ./compile c ./compile how to compile c file how to compile and run c program run and compile c program compile code in c can we compile c program with cc command compile c to so what do c compile to windows how to compile a c program how to run a compiled c file compile c source code compile program for c how to compile and run c c command compile how to compile c to .s compile c file with cl different ways to compile a c program c compiler compile c file in command prompt what does c compile to compile of c c compile example how to compile with c command to compile c program compile and run a c program how to compile c files how to compile a c program coimpile c file how to compile and run a c program how to run and compile c files how to quickly compile in c how to compile file in c how to compile and execute c program compile a c file compile c file compile file c only compile a program in c why use make to compile c how to compile a c command how to compile in c using make to compile c compile c programm compile c program compile c files how to compile c how to compile a c file compile c++ with gcc c how to compile how to compile c program compile with gcc command compile c compile c file to so how to compile in gcc how to gcc a c file gcc command line example compile a c program how to use make to compile c program compiling project with gcc compiling with gcc how to compile a c code how to compile c code windows 10 c compile so how to add c language lib gcc gcc compiling command make command and gcc c compile command gcc c file compilation line gcc compiler gcc example command gcc compile com buled so file compile c gcc gcc how to add .c files compile c code gcc compilaton compile and run c program how to compile c code to exe how to create a basic .so file make .so fle form c++cod ewith flags compile source code from command line c gcc how to compile c code gcc linux compile how to turn gcc compilation into application gcc compiler how to use how to compile c to .so creating .so file on linux gcc compile a file using make to create so file gcc compile c file creating .so file in linux gcc compile and run in one line linux compile usinng so file linux compile using so file how to use gcc compile in linux gcc How to build an .so file onlinux how to compile .so file in windows Which GCC command is to compile C code without linking ? which gcc command is to compile c code without linking gcc c file compile a .so file c to so file run .o file gcc gcc compilation steps compile c program gcc how to create .so file in linux compile c to so linux how to compile c code to a .so
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source