views:

457

answers:

1

I am using Eclipse IDE for C/C++ Developer- Build id: 20090920-1017

We know that eclipse for C++ has built-in 'coding aids' for C/C++ developers:

1) Code completion - Automatically complete/fill method names or fields names of a class or structure. Automatically populate class structures, for loops et al

2)Templates You can create and save templates for frequently used sections of code, which will be inserted according to scope. The Content Assist feature also provides quick access to code templates.

3)C/C++ Style profiles: K&R, GNU et al specify indentation, brace and other style issues.

Do you have experience creating your own C++ Style profiles to C++ mandate naming conventions ? Are Eclipse profiles something that can be effectively used to enforce code consistency automatically ?

( Code review is still required but prefer to use a tool to get the naming conventions, indentation et al at the outset)

Thanks, Jak

+1  A: 

Jay, I use my own C/C++ profiles in Eclipse - specifically, under Window|Preferences|C/C++|Code Style I have defined my own, which on here I'll call "Ninefinger's Code Profile". In there I've modified the options because I write with specific conventions, like this:

int add( int x, int y )
{
    int z = x + y;
    return z;
}

Eclipse won't stop me doing something different to that, but by default and for auto-generated bits it will fill in the options in my coding style.

Likewise you have default templates etc for headers and the like that can be used to adhere to the company standard.

One thing you might consider doing is writing plug-ins for Eclipse - an extension point exists for code-formatting: http://help.eclipse.org/galileo/topic/org.eclipse.cdt.doc.isv/reference/extension-points/org_eclipse_cdt_core_CodeFormatter.html which sounds pretty much like an additional plugin for achieving those templates above - don't get me wrong I don't know but I have some experience with extending other RCP apps - it might be this is how you do it and mandate that your developers pass their code through this formatter?

The full list of CDT extension points is available at: http://help.eclipse.org/galileo/topic/org.eclipse.cdt.doc.isv/reference/extension-points/index.html - an ideal solution for you I suppose would be one that treated formatting non-compliance as an error in the editor.

Ninefingers