警告级别
(更多警告
) 和 命令行 -> 附加选项
(-std=c99
)。但是我希望所有我的C项目默认都具有这种选项,而不是每次创建新项目时手动设置它们。
每个项目的配置属性都保存在\nbproject\configurations.xml
(%UserProfile%\Documents\NetBeansProjects\ProjectName\nbproject\configurations.xml
)文件中。
您可以在项目之间共享configurations.xml
文件,这样您就不必更改并应用每个设置。
您可以创建一个默认项目并按照自己的喜好进行配置。而不是创建一个新项目,您可以将其复制,然后命名为其他名称。
如果您希望工具链属性适用于每个项目,则需要手动修改工具链定义或创建一个新工具链。
Generate shadow copies of the tool collection descriptors:
%ProgramFiles%\NetBeans x\etc\netbeans.conf
:
%ProgramFiles%\NetBeans x\
.etc
folder > Properties > Security > Edit... > Under "Group and user names", select the "Users" group > Under "Permissions for Users", for "Full control", enable "Allow" > OK > OK.Open %ProgramFiles%\NetBeans x\etc\netbeans.conf
in a text editor that can handle the newlines.
On the line starting with netbeans_default_options
, add -J-Dcnd.toolchain.personality.create_shadow=true
to the string of values.
For example, the line may now look like:
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-Dcnd.toolchain.personality.create_shadow=true"
toolchain.properties
file in %Appdata%\NetBeans\x\config\Preferences\org\netbeans\modules\cnd\
. In toolchain.properties
, remove the line toolchain_shadow=true
, and save.
netbeans_default_options
, remove -J-Dcnd.toolchain.personality.create_shadow=true
from the string of values. In other words, undo the edit to restore the file back to its original state.Modify or create the toolchain definition:
%Appdata%\NetBeans\x\config\CND\ToolChain\
(7.2+) or %UserProfile%\.netbeans\x\config\CND\ToolChain\
(7.1.2-).MinGW.xml
.Within the c
element, there is a development_mode
element containing the different development mode option elements. You can modify the flags for a particular development mode by modifying the flags
attribute.
For example, when you add the -std=c11 -g3 -pedantic -Wall -Wextra -O0
flags, the attributes may look like this:
<development_mode>
<fast_build flags="-std=c11 -g3 -pedantic -Wall -Wextra -O0"/>
<debug default="true" flags="-std=c11 -g3 -pedantic -Wall -Wextra -O0 -g"/>
<performance_debug flags="-std=c11 -g3 -pedantic -Wall -Wextra -O0 -g -O"/>
<test_coverage flags="-std=c11 -g3 -pedantic -Wall -Wextra -O0 -g"/>
<diagnosable_release flags="-std=c11 -g3 -pedantic -Wall -Wextra -O0 -g -O2"/>
<release flags="-std=c11 -g3 -pedantic -Wall -Wextra -O0 -O2"/>
<performance_release flags="-std=c11 -g3 -pedantic -Wall -Wextra -O0 -O3"/>
</development_mode>
Within the cpp
element, there is a development_mode
element containing the different development mode option elements. You can modify the flags for a particular development mode by modifying the flags
attribute.
For example, when you add the -std=c++11 -g3 -pedantic -Wall -Wextra -O0
flags, the attributes may look like this:
<development_mode>
<fast_build flags="-std=c++11 -g3 -pedantic -Wall -Wextra -O0"/>
<debug default="true" flags="-std=c++11 -g3 -pedantic -Wall -Wextra -O0 -g"/>
<performance_debug flags="-std=c++11 -g3 -pedantic -Wall -Wextra -O0 -g -O"/>
<test_coverage flags="-std=c++11 -g3 -pedantic -Wall -Wextra -O0 -g"/>
<diagnosable_release flags="-std=c++11 -g3 -pedantic -Wall -Wextra -O0 -g -O2"/>
<release flags="-std=c++11 -g3 -pedantic -Wall -Wextra -O0 -O2"/>
<performance_release flags="-std=c++11 -g3 -pedantic -Wall -Wextra -O0 -O3"/>
</development_mode>
要在不同的平台上找到netbeans.conf
配置文件,请参见以下内容:
如何使我的自定义启动参数永久生效?
要在不同的平台上找到用户目录,请参见以下内容:
什么是userdir,我应该在哪里找到它?什么是cachedir,我应该在哪里找到它?
有关工具集描述符的信息,请参见以下内容:
使用C/C++工具集描述符-NetBeans IDE 6.9教程:
.exe
文件,该文件调用system
并将编译器/链接器作为第一个参数、配置文件中的其他参数以及最后添加所有实际的argv
参数。要么创建一个仅包含重定向器的全新目录,要么将所有旧的.exe
文件重命名为其他名称。 - user719662首先从Code::Blocks IDE下载和MSYS 1.0.11下载并安装Code::Blocks集成开发环境。
所有设置都将自动配置,但您必须从中选择“make”命令。
C:\msys\1.0\bin\make.exe
在Windows 7 Professional下使用NetBeans 8.1和MinGW(gcc),我找到了这个文件
C:\Users\Username\AppData\Roaming\NetBeans\8.1\config\Preferences\org\netbeans\modules\cnd*toolchain.properties*,
但是我找不到文件夹
C:\Users\Username\AppData\Roaming\NetBeans\8.1\config\CND
(所以我找不到C:\ Users \ Username \ AppData \ Roaming \ NetBeans \ 8.1 \ config \ CND \ ToolChain)
我找到了这个文件夹
C:\Users\Username\AppData\Roaming\NetBeans\8.1\config\Preferences\org\netbeans\modules\cnd
但那里没有MinGW.xml文件。我在安装NetBeans(和MinGW)的硬盘驱动器上找不到这个MinGW.xml文件。
XP1
是完全正确的,但在简单情况下,您可以使用 CFLAGS。 - user719662