Author Topic: [annoyance] Add New File (mostly headers) + Rename  (Read 13573 times)

Offline Wolf

  • Multiple posting newcomer
  • *
  • Posts: 30
[annoyance] Add New File (mostly headers) + Rename
« on: July 17, 2008, 09:58:10 pm »
Hello,
I noticed that even if I want to make a strict C project, when I insert a new file and make it a header, it defines it as a C++ header. Whenever I add files, if it doesn't know which language, it defaults to C++. Is it possible to change this behavior to make it default to C? If not, could an option to do so be added? It is annoying to always have to go to the file properties and change the compiler variable from CPP to CC. At some point, I thought I messed up something as it would allow me to use namespaces in a .c file. =P
What I'd prefer is to let the compiler decide how to compile the file according to its extension, and if I want to define a different behavior, then I can define this special compiler variable.
If I rename a .cpp file to a .c file, it still considers it C++. Which could be okay, but I believe it would be logical to care about the file extension and use the compiler variable for exceptions.
Thanks.

-- Wolf --

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: [annoyance] Add New File (mostly headers) + Rename
« Reply #1 on: July 26, 2008, 05:00:09 am »
Please give us some info?

Compiler?
Compiler Version?
Operating System?

Code::Blocks version or SVN?

Tim S

PS: Please post in the user forums in the future; instead of the "Developer forums (C::B DEVELOPMENT STRICTLY!) " forums.
« Last Edit: July 26, 2008, 05:04:08 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Wolf

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: [annoyance] Add New File (mostly headers) + Rename
« Reply #2 on: July 27, 2008, 11:24:29 pm »
Quote from: stahta01
Compiler?
Compiler Version?
This is related only to Code::Blocks projects.

Quote from: stahta01
Operating System?
Windows XP

Quote from: stahta01
Code::Blocks version or SVN?
8.02

Quote from: stahta01
PS: Please post in the user forums in the future; instead of the "Developer forums (C::B DEVELOPMENT STRICTLY!) " forums.
Yeah, sorry about that, the user forums were collapsed and my sight is playing tricks on me these days. Health ain't too great.

Quote from: stahta01
Please give us some info?
Whenever I add a header file to a project, Code::Blocks sets its compiler flags to CPP, even in a strict C project.
Code::Blocks considers files as C++ by default, unless the extension says otherwise, instead of letting the compiler decide of the kind of file. Even adding a ".asm" file to a project sets its compiler flags to CPP. And you can't blank out the compiler flags, as it will reset them to CPP. In other words, I have to manually change it for every header file I add to my project or whenever I rename files.
I think it would be better if C::B would let the compiler decide the kind of file (C or CPP) and set it only for exceptions. Or maybe allow the users to change the default behavior.

-- Wolf --

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: [annoyance] Add New File (mostly headers) + Rename
« Reply #3 on: July 28, 2008, 03:14:23 am »
I was able to duplicate what I think the problem is on both 8.02 and current SVN 5170.

Steps to duplicate are
1. File -> New -> Project
2. Pick "Console Application"
3. Select C language
4. Create an header file with .h extension
5. Use "Add Files" to add header
6. Look at the "Compiler Variable" it is CPP when CC makes more sense.
    Right click on header file;
    Properties
    advanced Tab

Tim S

PS, The problem is to deep in Code::Blocks for me. Looks like an SDK patch is needed to the cbProject::AddFile. You might try submitting it as an bug. Please include directions to duplicate the problem.


« Last Edit: July 28, 2008, 03:32:57 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org