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

Link error #5

Open
utmux opened this issue Sep 30, 2024 · 1 comment
Open

Link error #5

utmux opened this issue Sep 30, 2024 · 1 comment

Comments

@utmux
Copy link

utmux commented Sep 30, 2024

It is recommended to separate the class definition and implementation into two files, otherwise, it may lead to multiple definitions, which can cause link errors. For example:

// head1.hpp
#include "EasyBMP.hpp"
// main.cpp
#include "head1.hpp"

By splitting the class definition (EasyBMP.hpp) and implementation (EasyBMP.cpp), you avoid issues such as multiple definitions when including the header in different files.

@izanbf1803
Copy link
Owner

It is recommended to separate the class definition and implementation into two files, otherwise, it may lead to multiple definitions, which can cause link errors. For example:

// head1.hpp
#include "EasyBMP.hpp"
// main.cpp
#include "head1.hpp"

By splitting the class definition (EasyBMP.hpp) and implementation (EasyBMP.cpp), you avoid issues such as multiple definitions when including the header in different files.

The purpose of this library was to be minimal and keep it in a single file. This could be solved by adding preprocessor definitions and conditionals. Does this solution fit your needs? If it's the case, feel free to fork and start a pull request.

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

2 participants