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

redis-plus-plus fails to compile if prior to it's include the code includes <windows.h> and / or <shlwapi.h> #194

Closed
orennitzan opened this issue Mar 19, 2021 · 3 comments

Comments

@orennitzan
Copy link

Hi,
This is a nasty one.
I spent 3 days on it.
The problem:
When I include redis-plus-plus after some include that has, down the line includes of <windows.h> and / or <shlwapi.h>
The project will not compile and give errors like i forgot to put semicolon somewhere.
When commented it compiles fine.
When redis-plus-plus is included before those, also everything is fine.

// This is fine
#include <sw/redis++/redis++.h>
#include <windows.h>

// This will breake
#include <windows.h>
#include <sw/redis++/redis++.h>

Any idea?
Thanks

@sewenew
Copy link
Owner

sewenew commented Mar 20, 2021

@orennitzan I did some research, and it seems that the root cause is we must ensure to include winsock2.h before windows.h.

hiredis depends on timeval struct, and on Windows platform, this struct is defined in winsock2.h. So redis-plus-plus includes this header. However, there's some problem with winsock2.h and windows.h files, and we must ensure that winsock2.h is included before windows.h, otherwise, you'll get some wired errors. Please check the following links for reference:

Thanks for pointing this out! I'll add some document for this problem.

Regards

@orennitzan
Copy link
Author

@orennitzan
Copy link
Author

Thanks a lot sewnew.

@sewenew sewenew closed this as completed Jul 11, 2021
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