Skip to content

[demos] clang-cl compile error #26

Description

@gvanem

What is up with the state of the Windows code in the demos?
E.g. compiling http_server_demo/src/main.c using clang-cl v17.0.1 (for x64), gives me this error:

demo/http_server_demo/src/main.c(80,42): error: conflicting types for 'WaitForSingleObject'
   80 | __declspec(dllimport) uint32_t __stdcall WaitForSingleObject(
      |                                          ^
f:\gv\WinKit\Include\10.0.22621.0\um\synchapi.h(346,1): note: previous declaration is here
  346 | WaitForSingleObject(
      | ^
1 error generated.

There should be no need to prototype this OS-function (since <windows.h> should have been included already).
But pre-processing this files gives:

// From <synchapi.h>
__declspec (dllimport) DWORD __stdcall WaitForSingleObject (HANDLE hHandle, DWORD dwMilliseconds);

// From http_server_demo/src/main.c:
__declspec (dllimport) uint32_t __stdcall WaitForSingleObject (void *hHandle, uint32_t dwMilliseconds);

See, not really the same due to the typedefs according to clag-cl. But the same in practice.

With cl, there is only a warning:

demo/http_server_demo/src/main.c(81): warning C4028: formal parameter 2 different from declaration
demo/http_server_demo/src/main.c(81): warning C4142: 'WaitForSingleObject': benign redefinition of type
f:\gv\WinKit\Include\10.0.22621.0\um\synchapi.h(346): note: see declaration of 'WaitForSingleObject'

There is this same issue with all demo/*/main.c files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions