Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am implementing multilanguage code editor in c#.after typing program in editor when user presses compiler button,c compiler should take program typed(c program) in text area as input & should return its object that will contains corresponding output(output or error if any) .
1) firstly how to call or link c compiler to our c# program?
2)then how to carried out above scenerio?
3) how to catch output given by c compiler?
please suggest solution to above stuff.
with regards,
thimmanagouda patil
Posted
Comments
Andrew Brock 26-Feb-11 7:19am    
Be careful of licensing. You cannot redistribute most compilers, such as the Visual Compiler yourself, and I don't think you can distribute free compilers such as gcc if the product is sold.

Look at my Answer to similar question: providing COMPILER, DEBUGGER facility in IDE[^].

A key here is to catch compiler output in stdout and stderr from the process you spawn. I explained it in my Answer. You can re-direct the stream and ready it in some thread which is permanently working and is sleeping (mode exactly, waiting at the blocking stream read operation) when compiler is not working. Every time the thread read some unit of output or error, if should notify UI.

You cannot operate with UI controls from the thread. Instead, you should use Invoke of Invoke required methods of System.Windows.Forms.Control (Forms only) or System.Windows.Threading.Dispatcher (good for both Forms and WPF). I described all the details here: Control.Invoke() vs. Control.BeginInvoke()[^]. See also Problem with Treeview Scanner And MD5[^].

For thread, I recommend use my other Answer which advised to create a thread wrapper for passing parameters to the thread while avoiding type casting: How to pass ref parameter to the thread[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 26-Feb-11 10:30am    
Nice reply - my 5
Sergey Alexandrovich Kryukov 26-Feb-11 10:55am    
Thank you.
--SA
Take a look here[^] for some articles and suggestions on how to implement this.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Feb-11 21:21pm    
Sorry, Richard: I don't see how it answers more difficult question (3). Please see my Answer.
(so I did not vote this time)
--SA
Richard MacCutchan 26-Feb-11 5:02am    
That's because I did not answer it; I gave the OP some links to do some research on the subject since there is no simple answer to the question(s).
Sergey Alexandrovich Kryukov 26-Feb-11 13:24pm    
Sure, I understand. This was just to bring your attention to my Answer where all parts are addressed.
--SA

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