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:

  1. "Got started with CDT development", checked out org.eclipse.cdt.ui
  2. Opened src/org.eclipse.cdt.internal.ui.wizards.filewizard/NewSourceFileGenerator.java (actually I searched for the ".cpp" pattern and found it)
  3. "public static String generateHeaderFileNameFromClass(String className)" tells us about PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX
  4. We jump to PreferenceConstants.java and obtain the IPreferencesService path: nameStyle.cpp.source.prefix
  5. 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++?