Comments (7)
I have the convention that #include "..."
stands for a file inside the library and #include <...>
for a file outside the library.
Do you have any problem or counterargument to this convention?
from memory.
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
…
- How do you think about to avoid "a duplicated file search" here?
- Would you like to restrict the searched directories for header files of your software?
from memory.
Yes, I know the differences between "" and <> for header files.
But in the example you've pointed to, I've included a file in the current directory, so I've written "#include "detail/utility.hpp"
, which is exactly the purpose of "".
If I have used <>, it would not work since it is not on the search path, I've needed to write #include <memory/detail/utility.hpp>
or #include <foonathan/memory/detail/utility.hpp>
since the search path is depended upon a CMake option.
Please provide an example how the way I've used "" creates a real problem.
from memory.
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"?
from memory.
Let me elaborate my situation a little bit. I have the following directory structure:
include/
foonathan/
memory/
allocator_traits.hpp
tracking.hpp
The file tracking.hpp
includes the file allocator_traits.hpp
via "".
On all compilers I know the implementation-defined behavior means look in directory of tracking.hpp, so it will look and find allocator_traits.hpp
and include it. There is no need to retry the search with angle brackets.
If I've used <>, it would have looked in the search path. Depending on a CMake option, this is either include/foonathan/
or only include/
. It will not find the header in the search path, unless I change either the search path or the whole include statement.
As for the case where there is also a file allocator_traits.hpp
in the client code, this will not be included by the statement in tracking.hpp
so this is not a problem either.
from memory.
That is indeed the same convention I and many others use. It does not shock
me, for what it's worth.
For such low level header files, in a large project where compilation
performance is a very real issue, these sort of headers typically end up in
pre-processed header files where their cost is largely reduced to begin
with.
On Sun, Sep 13, 2015 at 6:44 AM, Jonathan Müller [email protected]
wrote:
Let me elaborate my situation a little bit. I have the following directory
structure:include/
foonathan/
memory/
allocator_traits.hpp
tracking.hppThe file tracking.hpp includes the file allocator_traits.hpp via "".
On all compilers I know the implementation-defined behavior means look
in directory of tracking.hpp, so it will look and find
allocator_traits.hpp and include it. There is no need to retry the search
with angle brackets.If I've used <>, it would have looked in the search path. Depending on a
CMake option, this is either include/foonathan/ or only include/. It will
not find the header in the search path, unless I change either the search
path or the whole include statement.As for the case where there is also a file allocator_traits.hpp in the
client code, this will not be included by the statement in tracking.hpp
so this is not a problem either.—
Reply to this email directly or view it on GitHub
#1 (comment).
from memory.
And since there is no overhead because the angle bracket search is not necessary and will fail, I am closing the issue now. If there is any more discussion, I will consider it again.
from memory.
Related Issues (20)
- Strange exception from unordered_set with memory_stack, on MSVC HOT 9
- Library triggers bug in MSVC++ v19 (VS 2022) under modern C++ standards, preventing compilation HOT 2
- `memory_pool_collection` carves too little memory from block if there are many buckets HOT 4
- [docs/examples] associative containers HOT 4
- memory_block_stack::owns() seems wrong? HOT 1
- Time for a new release? HOT 1
- problem with std::is_abstract for unique_ptr with allocator inside struct definition HOT 1
- give allocator_polymorphic_deleter a default constructor HOT 1
- Thread safety
- Build issues on MacOS while building tools with static flag HOT 3
- MinGW build fails due to "#warning" HOT 1
- Can a vector use a memory pool with a small_node_pool ?
- Unable to determine node size of C++ container HOT 4
- ARM64 crash when using static block allocator with small types HOT 2
- memory_pool_collection fails to allocate memory HOT 4
- Test fails on Android arm64-v8a
- memory pool allocate
- Wrap a memory_pool in a thread_safe_allocator? HOT 1
- Calling pure virtual function. HOT 1
- Page (4KiB) alignment for memory pool
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memory.