Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
How can i write a program using C# and visual studio 2017 that compile a code source writing on C programming, How can i do that? any simple solution to write this program? if not , so how can i use flex and bison for that program ? If C# didn't do this job, what is the perfect language that i can use to create this C compiler, thanks

What I have tried:

I tried to coding a program that can compile a C code source and show errors in output of my program (interface)
Posted
Updated 25-Nov-17 11:08am
v2
Comments
Rick York 25-Nov-17 15:27pm    
There are articles at this site that describe how to do this. Do some searching here, to start anyway.

Have you tried Googling for "How to write a C compiler[^]"?

This is not a trivial task. There is nothing simple about it.

Now, if you were looking to just compile C code, you could always just launch the CL.exe command line compiler.

I have no idea what the intent of this project is so it's impossible to tell you "what's best".
 
Share this answer
 
Comments
abdou_31 26-Nov-17 4:18am    
What is CL.exe?
Dave Kreskowiak 26-Nov-17 9:49am    
The C/C++ compiler in Visual Studio.
Building a C compiler from scratch, altough feasible, is rather complex.
Tools like flex and bison would actually simplify the task. However, they are C/C++ oriented. You might have a look at ANTLR[^].
 
Share this answer
 
Comments
abdou_31 26-Nov-17 4:17am    
I'm using C# right now , so how to add flex and bison to my project ?
CPallini 26-Nov-17 6:26am    
I won't use flex & bison with C#. Either change the tools or change the programming language.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900