开发者

How to write a C++ program on a mac that compiles and runs C++ code in a separate text file

I apologize in advance for asking this relatively uninformed question:

How can I get started learning to write a program in C++ that can compile C++ code that is stored elsewhere, for instance in a separate text file on the hard drive?

I need to write a program that makes modifications to the external code,开发者_运维知识库 and then runs different modified versions, in order to test the performance of varying combinations of parameters.

I am unsure if this is accomplished with an interpreter or compiler, or in another way. I am using xcode on mac os x 10.6.8.

Any help or direction is greatly appreciated, thank you.


Why not write a shell script that does whatever changes are needed (using sed or whatever makes sense for your case) and then kicks off a gcc command-line?


You can exec the compiler or, when looking towards 10.7 investigate Clang and LLVM which provides the compiler as a library.

http://clang.llvm.org/features.html#libraryarch

10.7 currently uses the GCC frontend to LLVM though, not Clang.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜