Skip to content

Fix compile-c-extension demo on windows #114

@finsberg

Description

@finsberg

The compile-c-extension demo currently doesn't work on Windows because MSVC wont compile it.

When running in CI we get the following output:

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(15,19): error C2057: expected constant expression [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(15,19): error C2466: cannot allocate an array of constant size 0 [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(15,12): error C2133: 'u_temp': unknown size [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(34,19): error C2057: expected constant expression [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(34,19): error C2466: cannot allocate an array of constant size 0 [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(34,12): error C2133: 'u_temp': unknown size [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(51,19): error C2057: expected constant expression [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(51,19): error C2466: cannot allocate an array of constant size 0 [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(51,12): error C2133: 'm_temp': unknown size [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(121,5): warning C4013: 'clock_gettime' undefined; assuming extern returning int [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(121,19): error C2065: 'CLOCK_MONOTONIC_RAW': undeclared identifier [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(128,19): error C2065: 'CLOCK_MONOTONIC_RAW': undeclared identifier [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(136,19): error C2065: 'CLOCK_MONOTONIC_RAW': undeclared identifier [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\demo.c(142,19): error C2065: 'CLOCK_MONOTONIC_RAW': undeclared identifier [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_examples_compile_c_extens0\compile-c-extension\build_ORdmm_Land\ORdmm_Land.vcxproj]

Windows users should use wsl if you need to compile the code in C. Since I am not using Windows myself, it is a bit hard to fix this. Any Windows users that are interested in helping out here are more than welcomed to submit a PR 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions