Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How do I use FASTER (C++) headers without filename collisions? #412

Closed
boinst opened this issue Feb 28, 2021 · 6 comments
Closed

Comments

@boinst
Copy link

boinst commented Feb 28, 2021

How do I use FASTER (C++) headers without filename collisions?

Sorry if this is a silly question. I have compiled the C++ version using CMake per the build directions. Now I'm working on integrating it with my project. The samples include FASTER headers as follows:

#include "core/faster.h"
#include "core/utility.h"
#include "device/file_system_disk.h"

Which is OK, but then "faster.h" includes a bunch of internal headers like "alloc.h" and "record.h" with no "core" or "device" prefix, as follows:

#include "alloc.h"
#include "record.h"
#include "guid.h"

Now surely this means I need the "core" and "device" header directories in my include paths? Surely the generic names like "alloc" and "record" have a strong risk of having the same name as another library or the same name as my own headers? Am I missing something obvious? Is this by design? The build system in my own project is Visual Studio C++, the intricacies of CMake are somewhat foreign to me.

Thanks sincerely in advance for any guidance you can provide.

@badrishc
Copy link
Contributor

badrishc commented Mar 1, 2021

See this issue and PR, perhaps something similar would work?

@boinst
Copy link
Author

boinst commented Mar 2, 2021

Thank you @badrishc those linked issues are relevant, but not quite the same issue. In this case I'm concerned about the collision of the header filename rather than the symbol. If I have "guid.h" in my own code (I don't, this is hyperthetical), I won't be able to successfully compile against FASTER. The compiler will resolve one or the other header but not both.
The only real fix for this, I would think, would be a significant change to the code base. Every #include "guid.h" in public headers would have to become #include "core/guid.h". Even better, #include "faster/core/guid.h". Before making such an intrusive PR though, I wonder if it would be welcome, or possibly against the design philosophy of this library?

@badrishc
Copy link
Contributor

badrishc commented Mar 2, 2021

Any thoughts @dongx-psu ?

@dongx-psu
Copy link
Contributor

I would put all faster header files under a directory called faster. And then include the upper-level directory as the root include directory. In this case, it forces you to add something like faster/core/faster.h in your program

@boinst
Copy link
Author

boinst commented Mar 3, 2021

Thank you @dongx-psu .

If I could simply include faster/core/faster.h as you suggest, that would be ideal.

I was surprised to find that when I #include "faster/core/faster.h", then guid.h on line 27 at least is correctly resolved. Today I learned that the current directory of the header being parsed is included in the search path for subsequent headers.

The first error I encounter is this one:

1>persistent_memory_malloc.h(13,10): fatal error C1083: Cannot open include file: 'device/file_system_disk.h': No such file or directory

That leads me to conclude that I still need to have the root faster directory in my include paths, and then I can include core/faster.h, but at least I don't need the core, device, etc sub-directories in my include paths. That's something, and that really resolves the larger fraction of my concern overall. Thank you for your guidance. Happy to close the ticket here if you're also happy.

@badrishc
Copy link
Contributor

badrishc commented Mar 3, 2021

I think it can be closed.

@badrishc badrishc closed this as completed Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants