Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

C++ headers have unnecessary includes #101

Open
SupSuper opened this issue Aug 20, 2019 · 2 comments
Open

C++ headers have unnecessary includes #101

SupSuper opened this issue Aug 20, 2019 · 2 comments

Comments

@SupSuper
Copy link
Contributor

Currently all the #includes for the source code are in the header files, which avoids repetition, but pollutes any users of the SDK with unnecessary dependencies and system headers, since there's no way to access the library API without the headers. Clean headers make it easier to integrate with third-party code and avoid unnecessary conflicts.

  • Given how C++ works, it's better to keep includes as close to the source as possible and avoid them in the header files, even if it causes repetition, since library headers can be included anywhere and pull everything along with them.
  • The source files (.cpp) should carry most of the includes, as they're the ones calling functions. Header files (.h) only need to include other headers for types and defines they reference.
  • The include/ folder should only contain header files with the library's public API (functions and classes exported by the DLL), all the others should stay in the src/ folder. The ModioC.h is a good example, as it defines nothing but the public API.

Tools like https://include-what-you-use.org/ can help automate this process.

@anishsingh935
Copy link

Hi can fix this issue .please assign me

@MarkusRannare
Copy link
Contributor

Hi,

Feel free do the changes =) Just to let you know, we won't maintain this repository for much longer as we have a version 2 of the SDK that's just about to go out of the door

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants