I've created a library using C++, I want to create a Python Wrapper for this library and I am using boost.python
- The problem is that I have created .h
and .cpp
files separately and for some reason, the .so file cannot link these .cpp files.
I have therefore decided to just use the .hpp extension and include the implementation as a header file. Is this good or bad practice in terms of C++? I'm hoping to upload my project to Github so want to maximize the most optimal solution.
P.S. I think this question would more belong on programmers.stackexchange.com so if it is, could someone please migrate it.
There are several applications that can be used to open HPP files such as Apple Xcode, Microsoft Visual Studio 2010, Code::Blocks, MacroMates TextMate, BloodshedSoftware Dev-C++, GNU project C and C++ compiler (GCC), etc.
h is more widely used for header files than . hpp when, . h refers to C header and . hpp refers C++ header.
The #ifndef directive checks whether a macro is not defined. If the identifier specified is not defined as a macro, the lines of code immediately follow the condition are passed on to the compiler.
Header files are used in C++ so that you don't have to write the code for every single thing. It helps to reduce the complexity and number of lines of code. It also gives you the benefit of reusing the functions that are declared in header files to different .
This is a good idea if you have mixed c++ and c in your project. As mentioned in the comments .hpp and .h are essentially the same (for compiling c++, not c). If you are having problems linking your project it's not because of your file extensions.
In the header files you typically 'prototype' the class definition so that all of your class members can be used, not just ones defined before the current code.
Please review: *.h or *.hpp for your class definitions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With