代码块:为stdin,stdout设置文件?

时间:2011-05-18 17:16:49

标签: linux codeblocks

如何在codeblocks ide中为stdin和stdout设置文件。如果我可以为每个构建目标设置不同,我会更好。它可能只是linux解决方案。

1 个答案:

答案 0 :(得分:1)

这不是IDE本身的问题,您需要通过编码来解决这个问题。 但假设您在CodeBlocks中有两个名为“Debug”和“Release”的构建目标。 转到项目 - >构建选项 - >编译器设置 - > #defines 对于Debug Target,给出一个宏:FOO_DEBUG和Release:FOO_RELEASE

最后在程序初始化的某个地方区分不同的构建目标,如:

#ifdef FOO_DEBUG
    freopen("in_d.log","r",stdin);
    freopen("out_d.log","w",stdout);
#else
    freopen("in_r.log","r",stdin);
    freopen("out_r.log","w",stdout);
#endif