Author Topic: How to change startup script for empty file to C++ from C  (Read 8051 times)

Offline zz

  • Single posting newcomer
  • *
  • Posts: 3
How to change startup script for empty file to C++ from C
« on: August 06, 2012, 03:42:58 pm »
When creating a new file, we can choose between, header, c++, or empty file.  The empty file option is convenience to have because it is also the first item under the new file icon.   The trouble is, this empty file defaults to C, instead of C++.  Therefore, when I want to do some quick c++ snippet code testing by opening an empty file, it is looking for a C compiler instead of the C++ compiler I want.   Yes, I understand I can change the C compiler option to the same as C++ compiler, but I want to know how to create a custom script for the empty file.  In other words, how can I make the empty file defaults to C++ compiler instead of defaulting to C compiler.
« Last Edit: August 06, 2012, 04:00:07 pm by zz »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to change startup script for empty file to C++ from C
« Reply #1 on: August 06, 2012, 06:53:21 pm »
If I create an empty file and name it with a c++ ending (cpp) it gets compiled by the c++-compiler.

So you must do something wrong.

Note C::B uses the file-ending to decide which compiler to use, if you do not set the appropriate property explicitely to something different (the file needs to belong to a project as far as I know).

Offline zz

  • Single posting newcomer
  • *
  • Posts: 3
Re: How to change startup script for empty file to C++ from C
« Reply #2 on: August 06, 2012, 07:18:42 pm »
Yes you are right, if I name my file  "sample.cpp" then it does get compiled as cpp file.   Will you give me one more tip on how to setup my code::block so that the default extension is *.cpp, i.e., if I provide no extension, then it defaults to *.cpp, instead of *.c.   I would like my empty file to default to *.cpp extension.   I don't want to type "sample.cpp" every time I saved the file.  Thank you !
« Last Edit: August 06, 2012, 07:20:53 pm by zz »