cpptask icon indicating copy to clipboard operation
cpptask copied to clipboard

Use of angle brackets around file names for include statements

Open elfring opened this issue 10 years ago • 4 comments

Would you like to replace any double quotes by angle brackets around file names for include statements?

elfring avatar Oct 28 '15 09:10 elfring

Could you please explain why you think that the angle brackets are preferable? Sorry, but from link you provided I didn't find a clean answer. I know that some times using angle brackets on non compiler specific headers leads to problems, because 3rd party library is not added to compiler include paths.

Kolkir avatar Oct 29 '15 22:10 Kolkir

I suggest to reconsider the consequences of the following wording from the section "16.2 Source file inclusion" in the standard specification for the programming language "C++".

…
The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read

#include <h-char-sequence> new-line
…

elfring avatar Oct 30 '15 09:10 elfring

Sorry, but I'm again missed the sense of using angle brackets for user libraries. As I understand using angle bracket can prevent situation of loading user header instead of system header if their names are the same (but it can hide a real problem). Personally I never met situations when 3rd party libraries are placed some where in the system, usually they placed in same code base with main project. Because in such case you can guarantee that the version of 3rd party library will be not changed independently from main project.

Kolkir avatar Oct 30 '15 10:10 Kolkir

There are different opinions about the handling of the involved implementation-defined behaviour.

  • Will header files be also searched outside the specified include directories if double quotes are used for the discussed preprocessor statement?
  • Is there a speed difference measurable if a file is not found there and the search will be retried with "the angle brackets inclusion method"?

elfring avatar Oct 30 '15 10:10 elfring