Fido icon indicating copy to clipboard operation
Fido copied to clipboard

Use of angle brackets around file names for include statements

Open elfring opened this issue 9 years ago • 20 comments

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

elfring avatar May 13 '16 18:05 elfring

@elfring Doesn't that mean that the library would have to be globally installed for it to build and run properly? Or would the include folder have to be marked as an include path by g++? Either way, what is the advantage over the double quotes?

truell20 avatar May 14 '16 15:05 truell20

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 May 14 '16 16:05 elfring

@FlyingGraysons @joshuagruenstein and I are a little unsure of what you are saying. Could you please clarify, @elfring?

truell20 avatar May 15 '16 16:05 truell20

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 May 15 '16 18:05 elfring

I believe that:

  • If double quotes are used, only the local and include directories are searched
  • If brackets are used, the system and include directories are search are search

I doubt that there is a measurable speed difference between the two methods.

I may be wrong though.

truell20 avatar May 17 '16 02:05 truell20

Can you imagine use cases where you would like to exclude the search in "local" directories?

elfring avatar May 17 '16 06:05 elfring

I cannot

truell20 avatar May 17 '16 16:05 truell20

@elfring Can you think of any use cases?

truell20 avatar May 17 '16 16:05 truell20

Yes. - This is the reason for my feature request here.

How much do you care where the include files are safely stored for a software library?

elfring avatar May 17 '16 16:05 elfring

@elfring What is the case?

hmwildermuth avatar May 17 '16 16:05 hmwildermuth

I find it important to be reasonably sure that the desired computations were really correct because it could be determined by the applied software build parameters that the used functions were actually derived from the expected source files. Can you follow this design concern?

elfring avatar May 17 '16 17:05 elfring

What do you mean by this: "the desired computations were really correct"?

truell20 avatar May 17 '16 23:05 truell20

I would generally prefer to exclude the potential for the inclusion of header files from unexpected directories. Can such a security detail become a bit more important occasionally?

elfring avatar May 18 '16 07:05 elfring

Yes, but the brackets mean that a person would have to specify an include directory, which is slightly annoying.

truell20 avatar May 18 '16 14:05 truell20

Will the mentioned "annoyance" vanish after safe include specifications would be used?

elfring avatar May 18 '16 14:05 elfring

Yes. This does sound like a good idea. Thank you for the feature request.

truell20 avatar May 18 '16 15:05 truell20

Would specifying the include directory in our g++ compilation command in our makefiles and switching the the brackets fix your specified problem?

truell20 avatar May 18 '16 15:05 truell20

How would you like to distinguish library versions by your software build system?

elfring avatar May 18 '16 15:05 elfring

Not sure? Any suggestions?

truell20 avatar May 18 '16 15:05 truell20

Feel free to submit a pull request that fixes the problem @elfring

truell20 avatar May 19 '16 21:05 truell20