Setting Default NetBeans Options (-std=c99, -Wall) for C programs
Asked Answered
R

3

19

I have NetBeans 6.9 installed and working fine on Ubuntu Linux 11.10. My goal is to set compiler options like -Wall and -std=c99 to be used by default. Currently, I have to right click on my project -> Properties -> C Compiler -> Warning Level to "More Warnings" and add -std=c99 to Additional Options. This is obviously a pain when creating many projects, and I'm sure there is a way to make all of this the default.

I found this thread which relates closely to my question. However, the only answer involves installing Code::Blocks and MSYS 1.0.11, which doesn't make much sense to me. I don't see how installing another IDE will help me, and MSYS seems unnecessary, as I am already using Linux.

I have tried every reasonable search term I can imagine, and am very surprised how little info I have turned up. It seems like most everyone who uses NetBeans should have to change this type of thing at some point. Terms I'm searching for: 'NetBeans -std=c99 default', 'NetBeans set default compile options', 'how to make NetBeans use c99 by default' and 'Code::Blocks settings into NetBeans'.

Rife answered 24/10, 2011 at 23:5 Comment(4)
I'm still not aware of an answer to this question, and I would still love to know if anyone has any info, btw. This question is very much still open.Rife
Please don't use link shorteners. Using link shorteners will prevent Stack Overflow from linking to related questions in the sidebar.Sanitation
What link shorteners? If any existed, you've already removed them or I'm somehow missing them.Rife
just a note: while XP1 is totally correct, in simple cases you may make do with just CFLAGSAribold
S
5

Here are some different things that you can do:

  1. Copy and share the configuration files between projects, so you won't have to set every setting.
  2. Create a default project, and configure however you like it. When you want to create a new project, just copy the default project and rename it to something else.
  3. Modify your toolchain properties.

For details, see here:

NetBeans settings for GCC

Sanitation answered 27/7, 2012 at 7:48 Comment(0)
C
1

You can create a Project Template Module. I was aware this is possible but didn't try it before, and this link is explaining how to do it;
https://blogs.oracle.com/seapegasus/entry/tip_create_your_own_project

(First you need NetBeans with platform SDK, not just C/C++ Bundle.)

I followed steps;

  • Open/Create your project with settings you want to use.
  • Create a NetBeans module project, choose a Code Base Name, i gave my.templates.ctemplate1
  • Add "Module Development > Project Template" to the module project. Choose your C project in "Select Project" step.
  • At next step select the Category as C/C++ and give a name for template i used MyCTemplate1.
  • Right click on module project and select "Create NBM", it will create my-templates-ctemplate1.nbm in the build folder of the module project.
  • Tools > Plugins > Downloaded , click "Add Plugin" and point to the nbm file in the build folder. Select install, it will give warnings because it's not signed.
  • When you want to create a new C/C++ project you will see your template in the wizard which will have all the settings as your first C project has.

Enjoy other possibilities; files, folders in original project will be there.

Chiquitachirico answered 8/9, 2015 at 22:24 Comment(0)
H
0

Have you tried editing your netbeans.conf file (for me, it's in /usr/local/netbeans-7.0.1/etc/netbeans.conf) and adding the options you need to the netbeans_default_options line? From looking at my version of the file, you might need to prepend -J to the switches (hence -Wall would become -J-Wall.)

Hatteras answered 25/10, 2011 at 13:44 Comment(3)
Thanks for the response! I tried appending -J-std=c99 -J-Wall to the end of the netbeans_default_options line. With that style, NetBeans would not launch. I then removed the -J options, so that I had appended -std=c99 -Wall. NetBeans would then launch, but no options had changed. I could not compile a for(int i = 0;;); loop, for example. My guess is that netbeans.conf is for Java options. There are lots of references to JVM and Sun, and none to C things. Tomorrow, I will look around for a .conf file I can use to modify C default options. Thank you for putting me on a fresh track!Rife
Sorry that didn't help you. I assume that you've already seen the Netbeans C/C++ Trail?Hatteras
I hadn't seen the trail, thanks for linking to it. I will have to explore it more later. I found a page about [bit.ly/tqQxqP netbeans.conf]. It seems that only [bit.ly/tsEGRl](these) start up parameters can be passed to NetBeans, either by the command line or the global or local version of netbeans.conf. None of those seem helpful, for this particular problem.Rife

© 2022 - 2024 — McMap. All rights reserved.