How to change the default C ++ file extension in Eclipse CDT when creating a new file?

My team was instructed to use a special coding standard, and part of this standard should use .cc as a suffix for class C implementation files (for the sake of argument, it could be .cxx, .C ++ or any number of other suffixes that are not .cpp).

We use the Eclipse CDT (C / C ++ Development Toolkit) for development, however in the "New C ++ Class" dialog box, when you enter the class name as the class name, for example, it automatically names your source file as Classname.cpp.

Of course, I can uncheck the "Use by default" checkbox and restore the suffix, but these are a few additional steps and a lot to ask each Engineer for a large ion project, which he needs to remember every time they create a new C ++ class.

I was stumped, however, trying to find an option that allows you to specify the default suffix for C ++ files in the Eclipse CDT. Do any Eclipse gurus know about this once?

+5
source share
4 answers

See Window> Preferences> C / C ++> Code Style> Name Style> Files> C ++ Source File> Suffix

+10
source

I dug out the 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

:

  • " CDT" , org.eclipse.cdt.ui
  • src/org.eclipse.cdt.internal.ui.wizards.filewizard/NewSourceFileGenerator.java ( ".cpp" )
  • "public static String generateHeaderFileNameFromClass (String className)" PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX
  • PreferenceConstants.java IPreferencesService: nameStyle.cpp.source.prefix
  • , .
+2

, Ogre Psalm33, 2013 .

Eclipse 4.4:

Window > Preferences > C/C++ > Code Style > Name Style > Files

: , Eclipse .h C++?

+2

Answer: It cannot be executed in Eclipse 3.6 (Helios) with CDT 7.0.0. See the Eclipse Bugzilla Record . Apparently, it is registered as an error / missing function, but no one is assigned to work on it.

+1
source

Source: https://habr.com/ru/post/1786228/


All Articles