CodeBlocks,GCC:改变项目语言c和c ++? [英] CodeBlocks, GCC: change project language c and c++?

查看:145
本文介绍了CodeBlocks,GCC:改变项目语言c和c ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我选择控制台项目开始,它让你选择c或c ++,但一旦它创建..我不知道在哪里更改它,当你创建一个win32 gui应用程序,它不给你的选项,它的默认值是c ++ ..在哪里可以更改为c?我一直在寻找AGES的所有项目设置。将我的文件从cpp重命名为.c似乎没有做任何事情,它将文件编译为cpp。我知道没有ide,你只是把你的exe从g ++更改为gcc,但是如何设置这个为当前项目在代码块?

When I select console project to start with, it lets you select c or c++, but once its created.. i can't figure out where to change it, and when you create a win32 gui application, it doesn't give you the option at all, and its default is c++.. where can i change to c? i have been looking in all the project settings for AGES. renaming my file from cpp to .c doesn't seem to do anything, it compiles the file as cpp. i know that without the ide, you just change your exe from g++ to gcc, but how do i set this for the current project in codeblocks?

推荐答案

创建项目时选择C和C ++之间的唯一具体区别是在构建期间为翻译单元调用哪个编译器。代码块目前不提供在项目创建后直接改变这种方式。也就是说,你必须每次更改一个源文件,以获得你想要的。

The only tangible difference between selecting C vs C++ when you create a project is which compiler is invoked for the translation units during a build. Codeblocks currently does not provide a way to directly change this after project creation. That is to say you would have to change each source file one at a time to get what you want.

这里是你可以做的更改它:

Here's what you can do to change it:


  • 打开要更改源的属性窗口。您可以通过右键点击源文件 - >属性来实现。

  • Open the properties window for a source you want to change. You can get to it by right-click source file->properties.

查找编译器变量字段并更改从CPP到CC。

Find the Compiler variable field and change it from CPP to CC.

<

现在如果你现有的项目包含很多源文件,你可以通过手动编辑代码块cbp项目文件(它只是一个xml文件)来做到这一点。要搜索和替换的节点将如下所示:

Now if your existing project contains a lot of source files you can do this quicker by manually editing the codeblocks cbp project file (it's just an xml file). The nodes you want to search for and replace will look something like this:

<CodeBlocks_project_file>
        //...
  <Project>
        //...
    <Unit filename="source1.cpp">
      <Option compilerVar="CPP" />  //change CPP to CC here
    </Unit>
    <Unit filename="source2.cpp">
      <Option compilerVar="CPP" />  // and here
    </Unit>
    <Unit filename="source3.cpp">
      <Option compilerVar="CPP" />  // and here then save.
    </Unit>
    //...
  </Project>
</CodeBlocks_project_file>

更改在C :: B中打开您的项目并确认它正在编译为C源文件。您应该看到构建日志现在调用gcc而不是g ++。

After the changes open your project in C::B and confirm it's being compiled as a C source file. You should see the build log invoking gcc now instead of g++.

这篇关于CodeBlocks,GCC:改变项目语言c和c ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆