Include header files always with < > instead of ""

Resharper always uses < > instead of " " for not predefined header files. It's there any way to configure?

0
4 comments
Avatar
Permanently deleted user

Hello David,

There's currently no way to configure that, but R++ tries to be smart about which include form to use and the actual behaviour is more complicated. The set of paths that the angle-bracket include directive uses to resolve file paths is a subset of the one that quoted form uses (https://msdn.microsoft.com/en-us/library/36k2cdd4.aspx), so R++ tries to prefer the angle-bracket form. The algorithm looks something like this:

1) If angle-bracket form can be used and the file is not in the same project, use angle brackets.
2) Otherwise, fall back to the quoted form.

Could you please elaborate on why you want to use "" instead of <> and describe how your includes are organized?

Thanks!

0

I also find this issue a little bit annoying.  I personally don't have any strong convictions about whether <> or "" should be preferred for used for #includes but the general consensus on the (very large) project that I'm working on is to prefer quotation marks for including any file that's "our code" and angle brackets are typically only used for "system" headers, e.g. things like <windows.h>, <stdio> or headers from 3rd party libraries that we use.  The large majority of the #include statements are for our own code including our own code, and so tend to use quotation marks.  So when resharper adds an #include with angle brackets it just looks conspicuous and I worry that if I submit the code people will come and question me about why I'm breaking the trend.  Telling them that I'm just being lazy and leaving it the way resharper wants to add it doesn't sound like it would be a very good reason.

So from my perspective it would be nice if I could either configure it to always use quotation marks whenever the header is part of the current VS .sln.

 

 

0
Avatar
Permanently deleted user

Mike,

Thanks for the suggestion, makes total sense - I filed https://youtrack.jetbrains.com/issue/RSCPP-16862 and we'll add the option by the next release.

I must point out again that the quoted form uses more complicated lookup rules and is susceptible to conflicts - say if your .cpp included a file from another folder using a quoted form, and you add a file with the same name to the .cpp file's folder, then include directive will start resolving to another file. But I do understand that the convention to use quoted includes for solution members is common.

Thanks!

0
Avatar
Permanently deleted user

The latest EAP build available from https://confluence.jetbrains.com/display/ReSharper/ReSharper+2016.2+EAP should have the option to prefer "" to <> for files belonging to the same project or solution. Please see my remarks in https://youtrack.jetbrains.com/issue/RSCPP-16862.

0

Please sign in to leave a comment.