[go: up one dir, main page]

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

examples: fix compiling with MSVC #13771

Closed
wants to merge 7 commits into from
Closed

Conversation

vszakats
Copy link
Member
@vszakats vszakats commented May 24, 2024
  • websocket.c: use Sleep() on Windows.
    sleep() and unistd.h are not available in MSVC.

  • http2-upload.c: use local gettimeofday() implementation
    when compiled with MSVC.
    (Alternate solution is to disable the trace function for MSVC.)
    Public domain code copied and adapted from libssh2:
    https://github.com/libssh2/libssh2/blob/e973493f992313b3be73f51d3f7ca6d52e288558/src/misc.c#L719-L743

  • silence compiler warning for deprecated inet_addr().
    Also drop duplicate winsock2 include.

    curl\docs\examples\externalsocket.c(125,32): error C2220: the following warning is treated as an error [curl\bld\docs\examples\curl-example-externalsocket.vcxproj]
    curl\docs\examples\externalsocket.c(125,32): warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings [curl\bld\docs\examples\curl-example-e
    

    Ref: https://github.com/curl/curl/actions/runs/9227337318/job/25389073450#step:4:95

  • silence an MSVC compiler warning. This is in conflict with
    checksrc rules, so silence the rule in favour of the
    warning-free C syntax.

    curl\docs\examples\multi-legacy.c(152,1): error C2220: the following warning is treated as an error [curl\bld\docs\examples\curl-example-multi-legacy.vcxproj]
    curl\docs\examples\multi-legacy.c(152,1): warning C4706: assignment within conditional expression [curl\bld\docs\examples\curl-example-multi-legacy.vcxproj]
    

    Ref: https://github.com/curl/curl/actions/runs/9227337318/job/25389073450#step:4:226

  • do not use sys/time.h and unistd.h in Windows builds.
    Some of these includes look unnecessary. Subject to another
    PR.

Cherry-picked from #13766
Closes #13771

```
curl\docs\examples\externalsocket.c(125,32): error C2220: the following warning is treated as an error [curl\bld\docs\examples\curl-example-externalsocket.vcxproj]
curl\docs\examples\externalsocket.c(125,32): warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings [curl\bld\docs\examples\curl-example-externalsocket.vcxproj]
```
Ref: https://github.com/curl/curl/actions/runs/9227337318/job/25389073450#step:4:95
```
curl\docs\examples\multi-legacy.c(152,1): error C2220: the following warning is treated as an error [curl\bld\docs\examples\curl-example-multi-legacy.vcxproj]
curl\docs\examples\multi-legacy.c(152,1): warning C4706: assignment within conditional expression [curl\bld\docs\examples\curl-example-multi-legacy.vcxproj]
```
Ref: https://github.com/curl/curl/actions/runs/9227337318/job/25389073450#step:4:226
@vszakats vszakats mentioned this pull request May 24, 2024
3 tasks
Also drop winsock2 include. `curl/curl.h` already includes it.
vszakats added a commit to vszakats/curl that referenced this pull request May 25, 2024
Cherry-picked from curl#13771
Closes #xxxxx
@vszakats vszakats removed the cmake label May 26, 2024
@vszakats vszakats closed this in d4b8589 May 26, 2024
@vszakats vszakats deleted the msvc-examples branch May 26, 2024 20:44
vszakats added a commit that referenced this pull request May 27, 2024
Continuing the theme, add 3 MSVC jobs with tests, matching
configurations used on AppVeyor. MSVC versions are identical:
19.39.33523.0 + Windows SDK 10.0.22621.0.

Also enable websockets, and build examples. Tests are run in parallel
(`-j14`), with improved performance.

Job performance:
```
                                                       AppVeyor  GHA
                                                                 w/examples
                                                       --------  ----------
CMake, VS2022, Debug, x64, Schannel, Static, Unicode   38m 4s    11m57s
CMake, VS2022, Debug, x64, no SSL, Static              35m15s    12m 6s
CMake, VS2022, Debug, x64, no SSL, Static, HTTP only   25m25s    10m36s
```
Based on these runs:
https://ci.appveyor.com/project/curlorg/curl/builds/49884748
https://github.com/curl/curl/actions/runs/9229448468

This is the first time examples are built in CI with MSVC: Fix all
warnings and errors that came up via
d4b8589 #13771.

Closes #13766
vszakats added a commit that referenced this pull request May 27, 2024
Delete a bunch of unnecessary-looking headers from some examples. This
is known to be tricky on AIX (perhaps also in other less-tested envs).

Let me know if any of this looks incorrect or outright fails on some
systems.

Follow-up to d4b8589 #13771
Closes #13785
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

2 participants