Snaipe / Mimick

A KISS, cross-platform C mocking library
MIT License
152 stars 43 forks source link

Build fails on MSYS2 UCRT with incompatible pointer type in vitals.c #44

Open brendan-simon-indt opened 2 months ago

brendan-simon-indt commented 2 months ago

I use MSYS2 (UCRT environment) and am having trouble building Mimick. I run cmake . and ninja and get an error about incompatible pointer type in vitals.c:182:27

$ cmake .
-- Building for: Ninja
CMake Deprecation Warning at CMakeLists.txt:5 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/ucrt64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: C:/msys64/ucrt64/bin/cc.exe
-- Looking for __stdio_common_vfprintf
-- Looking for __stdio_common_vfprintf - found
-- Configuring done (3.0s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/BrendanSimon/SW/Mimick
$ ninja.exe 
[1/4] Building C object CMakeFiles/mimick.dir/src/vitals.c.obj
FAILED: CMakeFiles/mimick.dir/src/vitals.c.obj
C:\msys64\ucrt64\bin\cc.exe -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS -IC:/Users/BrendanSimon/SW/Mimick/include -IC:/Users/BrendanSimon/SW/Mimick/src -std=c99 -Wall -Wextra -Wno-unused-parameter -MD -MT CMakeFiles/mimick.dir/src/vitals.c.obj -MF CMakeFiles\mimick.dir\src\vitals.c.obj.d -o CMakeFiles/mimick.dir/src/vitals.c.obj -c C:/Users/BrendanSimon/SW/Mimick/src/vitals.c
C:/Users/BrendanSimon/SW/Mimick/src/vitals.c: In function 'mmk_init_vital_functions':
C:/Users/BrendanSimon/SW/Mimick/src/vitals.c:182:27: error: assignment to 'void (*)(FILE *, const char *, char *)' {aka 'void (*)(struct _iobuf *, const char *, char *)'} from incompatible pointer type 'int (*)(FILE *, const char *, char *)' {aka 'int (*)(struct _iobuf *, const char *, char *)'} [-Wincompatible-pointer-types]
  182 |             mmk_vfprintf_ = win32_vfprintf_fallback;
      |                           ^
ninja: build stopped: subcommand failed.
brendan-simon-indt commented 2 months ago

Changing the declaration of line 131 fixed it for me.

from:

void (*mmk_vfprintf_)(FILE *, const char *, va_list);

to:

int (*mmk_vfprintf_)(FILE *, const char *, va_list);