Skip to content

library interfaces: remove dependency on config.h #6274

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

davidpanderson
Copy link
Contributor

We need to be able to compile with libboinc and libboinc_api without needing config.h.

To do this: avoid having .h files include other .h files
(in particular, avoid chains of includes that lead to str_replace.h,
which is what needs config.h).

Fixes #6271

We need to be able to compile with libboinc and libboinc_api
without needing config.h.

To do this: avoid having .h files include other .h files
(in particular, avoid chains of includes that lead to str_replace.h,
which is what needs config.h).
@Copilot Copilot AI review requested due to automatic review settings April 22, 2025 20:53
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes unnecessary dependencies on config.h by reducing header interdependencies and replacing includes with forward declarations where possible.

  • Updated test files to include missing headers for error numbers and parsing.
  • Replaced direct inclusion of specific headers in library files with forward declarations.
  • Modified MIOFILE from a class to a struct in header files to avoid including config.h unnecessarily.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit-tests/lib/test_str_util.cpp Added include for error_numbers.h to support testing functionality
tests/unit-tests/lib/test_parse.cpp Added include for parse.h to support testing functionality
lib/win_util.cpp Added include for error_numbers.h to resolve dependency
lib/util.cpp Added include for str_replace.h in implementation file
lib/str_util.h Removed include of str_replace.h to break dependency chain
lib/proxy_info.h Replaced a class declaration with a forward declaration for MIOFILE
lib/opencl_boinc.h Replaced header includes with forward declarations to eliminate dependency chains
lib/miofile.h Changed MIOFILE from a class to a struct to simplify interface declarations
lib/coproc.h Removed parse.h include while adding forward declarations
lib/common_defs.h Replaced includes with forward declarations to reduce dependency on config.h
lib/app_ipc.cpp Added include for str_replace.h as needed in the implementation
client/hostinfo_linux.cpp Adjusted include order to support new dependencies
client/client_msgs.h Updated function signature by removing redundant 'class' keyword
Comments suppressed due to low confidence (2)

lib/miofile.h:42

  • Changing MIOFILE from a class to a struct alters the default access level for its members; please confirm that all member variables and functions are intended to be public.
-class MIOFILE {

client/client_msgs.h:47

  • [nitpick] Removing the redundant 'class' keyword in the function parameter improves clarity; please ensure the corresponding implementation is updated accordingly.
void write(int seqno, class MIOFILE&, bool translatable);

@AenBleidd
Copy link
Member

I keep this open for a while to make a full test with building libboinc independently and linking to the test code.
Should take me a couple of days to do that.

@davidpanderson
Copy link
Contributor Author

BTW, the test is: compile an app that uses libboinc_api and libboinc
(and therefore includes api/boinc_api.h and e.g. lib/util.h)
without config.h anywhere.
I did this using samples/example_app/ (by renaming boinc/config.h)
on Win and Linux and it worked.

@AenBleidd
Copy link
Member

That's similar to what I plan to do, with the only different that in my case I want to have these builds separated, and the app should not have physical access to the 'config.h' file to be sure that there is no other hidden place.
And I want to make it another automated test to prevent such cases in the future.
Anyway, thank you for the fix, @davidpanderson 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

Installed header str_replace.h includes config.h, which should never be installed
2 participants