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

Fails to compile with the latest MSVC 2019 x64 and C11 (C99 is OK) #68

Open
HappySeaFox opened this issue Nov 30, 2020 · 2 comments
Open

Comments

@HappySeaFox
Copy link

HappySeaFox commented Nov 30, 2020

Hi! Thanks for the great library!

With the latest MSVC (Community) update munit fails to compile when the C standard version is set to C11. With C99 it works fine. C11 used to work fine before the update.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)

project(MUNIT-TEST VERSION 1.0.0
             LANGUAGES C)

set(CMAKE_C_STANDARD 11) # HERE
set(CMAKE_C_EXTENSIONS OFF)

add_executable(munit-test munit.c main.c)

main.c:

#include "munit.h"

int main(int argc, char *argv[])
{
    return 0;
}

cmake -A x64 ..:

D:\projects\munit-test\build>cmake -A x64 ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 6.1.7601.
-- The C compiler identification is MSVC 19.28.29334.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/projects/munit-test/build

cmake --build . --config Release:

Microsoft (R) Build Engine версии 16.8.2+25e4d540b для .NET Framework
(C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.

  munit.c
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(9461,5): warning C5105: macro expansion producing 'defined' has undefined behavior [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(403,81): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(403,81): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(465,118): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(465,118): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(474,139): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(480,83): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(480,83): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(152,38): error C2054: expected '(' to follow '_Thread_local' [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(152,64): error C2085: 'munit_error_jmp_buf_valid': not in formal parameter list [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(152,64): error C2143: syntax error: missing ';' before '=' [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(153,35): error C2054: expected '(' to follow '_Thread_local' [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(153,54): error C2085: 'munit_error_jmp_buf': not in formal parameter list [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(169,111): error C2085: 'munit_logf_exv': not in formal parameter list [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(169,111): error C2143: syntax error: missing ';' before '{' [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(204,17): warning C4013: 'munit_logf_exv' undefined; assuming extern returning int [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(223,34): error C2065: 'munit_error_jmp_buf_valid': undeclared identifier [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(224,34): error C2065: 'munit_error_jmp_buf': undeclared identifier [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(224,34): warning C4047: 'function': '_JBTYPE *' differs in levels of indirection from 'int' [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(224,15): warning C4024: 'longjmp': different types for formal and actual parameter 1 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(239,32): error C2065: 'munit_error_jmp_buf_valid': undeclared identifier [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(240,32): error C2065: 'munit_error_jmp_buf': undeclared identifier [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(240,32): warning C4047: 'function': '_JBTYPE *' differs in levels of indirection from 'int' [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(240,13): warning C4024: 'longjmp': different types for formal and actual parameter 1 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(939,103): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(939,103): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(956,74): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(956,74): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1077,97): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1077,97): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1430,9): error C2065: 'munit_error_jmp_buf': undeclared identifier [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1430,9): warning C4047: 'function': '_JBTYPE *' differs in levels of indirection from 'int' [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1430,9): warning C4024: '_setjmp': different types for formal and actual parameter 1 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1434,33): error C2065: 'munit_error_jmp_buf_valid': undeclared identifier [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1700,72): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1700,72): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1836,79): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(1836,79): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(2053,72): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.c(2053,72): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
  main.c
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(9461,5): warning C5105: macro expansion producing 'defined' has undefined behavior [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(403,81): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(403,81): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(465,118): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(465,118): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(474,139): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(480,83): error C2057: expected constant expression [D:\projects\munit-test\build\munit-test.vcxproj]
D:\projects\munit-test\munit.h(480,83): error C2466: cannot allocate an array of constant size 0 [D:\projects\munit-test\build\munit-test.vcxproj]
  Generating Code...
@codylico
Copy link

outsider comment:
some of those errors look like MSVC doesn't like MUNIT_ARRAY_PARAM. i'm not sure why the _Thread_local complaints are there, though.

@HappySeaFox
Copy link
Author

#71

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