How to change the default C++ file extension in Eclipse CDT when creating a new file?
See Window > Preferences > C/C++ > Code Style > Name Style > Files > C++ Source File > Suffix
I've digged Eclipse CDT code and found a solution:
append
nameStyle.cpp.source.suffix=.cc
to
<workspace location>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.ui.prefs
Here is how I did it:
- "Got started with CDT development", checked out org.eclipse.cdt.ui
- Opened src/org.eclipse.cdt.internal.ui.wizards.filewizard/NewSourceFileGenerator.java (actually I searched for the ".cpp" pattern and found it)
- "public static String generateHeaderFileNameFromClass(String className)" tells us about PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX
- We jump to PreferenceConstants.java and obtain the IPreferencesService path: nameStyle.cpp.source.prefix
- This article nicely explains where the prefs are stored
The bug mentioned by Ogre Psalm33 was fixed in 2013.
The location in Eclipse 4.4 is:
Window > Preferences > C/C++ > Code Style > Name Style > Files
Related: Make Eclipse treat .h file as C++?