Question:
How to compile C function (from external txt file) in runtime of C++ program?
Rootis
2009-10-28 04:29:06 UTC
Hi, I use windows 7 and visual studio 2008 professional (for C++). I try to develop an app (with GUI), which can to compile an external C function. Function is simple, but big. Function name and parameters are always the same (const). That how it should work: user runs my C++ program, under "browse" field he choose a file (which contains C function), then, my app reads that file, compiles the function and executes it.

How can I do that?

I tried to use tinycc library, everything was perfect, until I tried to compile big function... When function size in cache exeeds 4096 limit, then windows are trying to launch "__chkstk" function and everything crashes. And I don't know the other way how to solve this problem.
Three answers:
anonymous
2009-10-28 23:45:03 UTC
Hm....



















Try compile with LARGE MODEL or HUGE MODEL
satsumo
2009-10-29 03:13:04 UTC
How about using the Visual C++ compiler. On my computer it's C:\Program Files\Microsoft Visual Studio\VC98\Bin\cl.exe, you run it like any other command line program.



One way to get the command line parameters is to compile one of the C files into an exe in Developer Studio and see what parameters it puts in the project settings.



There is also link.exe in the same folder put you can get cl.exe to link if you give it the correct parameters.



You might want to capture the output so you can show it to the user if the compile fails. You know how to call command line stuff at runtime?
dickensheets
2016-10-15 05:54:36 UTC
fopen_s is microsofts attempt to interchange fopen. you could the two change to apply fopen_s, detect a thank you to disable this microsoft characteristic, or use yet another compiler like gcc. corresponding to strcpy and strcpy_s.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...