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

windows headers are included - windows macros create problems #618

Closed
ivannp opened this issue Oct 30, 2024 · 2 comments · Fixed by #621 or #623
Closed

windows headers are included - windows macros create problems #618

ivannp opened this issue Oct 30, 2024 · 2 comments · Fixed by #621 or #623

Comments

@ivannp
Copy link

ivannp commented Oct 30, 2024

Describe the bug
quill includes windows headers. This is a problem, because many windows functions are in fact macros. If there is a function in the project called GetObject, it's expanded by the windows GetObjectA or GetObjectW, which is horrible.

To Reproduce
Include quill/Logger.h and create a class with a GetObject method.

Expected Behaviour
Not bringing in windows.h is ideal.

Environment Details

  • Library Version: latest
  • Linkage: static
  • Operating System: windows
  • Compiler: msvc
@odygrd
Copy link
Owner

odygrd commented Oct 30, 2024

I tried to remove windows.h from Logger.h a few months ago. Since Logger.h and Metadata.h are the only headers needed for logging, it would be ideal not to include windows.h there. However, it wasn’t possible at the time. We rely on some OS-specific functions, and windows.h defines preprocessor variables that are necessary for the underlying headers, so simply including those headers didn’t work.

To minimize issues, we define LEAN_AND_MEAN and NO_MINMAX before including windows.h.

I’ll give it another try in the next few days and see if there's a way around this.

@odygrd odygrd linked a pull request Oct 31, 2024 that will close this issue
@odygrd
Copy link
Owner

odygrd commented Oct 31, 2024

This update removes windows.h from Logger.h by forward-declaring the necessary functions. Now, if you build a wrapper as shown in the example below:

https://github.com/odygrd/quill/blob/master/examples/recommended_usage/recommended_usage.cpp

you should be able to log without including windows.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants