soci icon indicating copy to clipboard operation
soci copied to clipboard

soci-mysql.h should not include winsock.h

Open Astrinus opened this issue 6 years ago • 4 comments

mysql.h from MySQL Connector/C 6.1 includes winsock2.h, so when including soci/soci-mysql/soci-mysql.h an enormous number of errors are spit out by MSVC because of conflicting declarations.

Astrinus avatar Apr 04 '18 13:04 Astrinus

Thanks for reporting. Feel free to submit a pull request.

mloskot avatar Apr 04 '18 13:04 mloskot

I think that previous versions of Connector/C required that line, but which ones? A simple removal would likely break other older codebases. What's the connector version used on the CI environments?

Astrinus avatar Apr 04 '18 15:04 Astrinus

I can't tell the versions from top of my head. It's likely default packages from Ubuntu Precise in case of Travis CI.

If you know

  • version of the Connector you are using, for which the compilation is failing
  • how to detect the connector version at compile-time or from CMake then we can probably #ifdef the #include <winsock2.h>`.

Or, just submit a PR and let's see if the Travis CI or AppVeyor are still green. If they are, then we are good :)

mloskot avatar Apr 04 '18 16:04 mloskot

I'm using Connector/C 6.1.11. ...That reminds me that CMake is unable to find automatically the Connector, I specified the paths manually. It seems that tries to find only the full database or its embedded version. I'll think about it... even if, personally, I'd rather send MySQL to the bit bucket right away.

Anyway, the latest MySQL release (5.7.21) already includes winsock2.h by itself, so AppVeyor must use an older version. On Chocolatey the last version is 5.7.18, but it already includes that header...

Obviously the problem does not show up on Linux, since I don't think there is WINsock on it ;-)

Astrinus avatar Apr 06 '18 12:04 Astrinus