Search code examples
c++eclipsegeneratoreclipse-cdt

Eclipse c++ class generation formating


I've switched to Eclipse Mars.1 and I can't figure out how to fix this.

Here's the problem:

I right click on the subfolder MySubFolder and choose New->Class

In Class name field I enter MyClass and fill the namespace with MySubFolder and click on Finish

The generated .cpp has the partner include surounder with angle bracket and full path :

#include <MySubFolder/MyClass.h> 

I want it that way :

#include "MyClass.h"

I tried ticking C/C++->Code Style->Include Style->Closely Related Headers->Partner Header->Use path relative to the including file

And made sure "Use angle bracket" was not set for the same option but none will do


Solution

  • You have "src" directory in your include paths you are passing to the compiler.

    For example if I have "${workspace_loc:/${ProjName}/src}" listed in my include paths like this:

    enter image description here then CDT uses angle brackets relative to "${workspace_loc:/${ProjName}/src}" to calculate include directory.

    You may also have the include paths in the auto-discovered or manually managed section if you are not using CDT's managed build projects (e.g. you write your own makefiles, or use tools like cmake), like this:

    enter image description here

    If you create a class not within any include directory, it uses double-quotes.