Menu

#411 WIN32: MSVC: cannot build opencbm

v3.x
wont-fix
gpz
None
bugfix
2025-12-01
2025-11-29
No

Actually, this is not exactly a bug of VICE, but it's into the header of opencmb.
While compiling C code on Windows you can have these macros:

  • _WIN32 when compiling for target "Windows". Somehow, it is an intrinsic symbol.
  • WIN32 after you have included Windows.h.
    The combination of these 2 macros allows you to distinguish between several scenario.
    However, opencbm.h checks WIN32 before including Windows.h, so it won't be able to find it and it will never include that, unless you define yourself WIN32 into the properties of the project.
    So, the right macro to test is _WIN32 and not WIN32.
    Attached patch shows you a possible fix.
1 Attachments

Discussion

  • gpz

    gpz - 2025-11-29

    this fix needs to be applied upstream then (anything in src/lib/ is just copied 1:1 from upstream, we don't modify those)

     
  • gpz

    gpz - 2025-11-30

    upstream is here: https://github.com/OpenCBM/OpenCBM

    That said, why does it even work in our windows builds then, and how is it a problem in MSVC on the other hand?

     
  • Carlo Bramini

    Carlo Bramini - 2025-11-30

    I think that it works because MinGW defines both _WIN32 and WIN32 (just tested), while Microsoft C compiler defines only _WIN32.
    However, WIN32 can be also added into the options of the preprocessor into Visual Studio, if someone wants, so this patch is not strictly required.

    However, it is also a good idea to signal this issue to the developers at OpenCBM, in my opinion.

     

    Last edit: Carlo Bramini 2025-11-30
  • gpz

    gpz - 2025-11-30

    I see. I'd just add it to the options in MSVC in that case - but obviously feel free to report it to the opencbm guys :)

     
  • gpz

    gpz - 2025-11-30

    i actually produced a working windows build in msvc now - without touching this file. shrug

     
  • Carlo Bramini

    Carlo Bramini - 2025-11-30

    After reading your message, I also tried and you are right.
    I'm 100% sure that the Microsoft C/C++ compiler doesn't define WIN32 but only _WIN32 (I just tried to make a test) and in the past I was forced to do that change because an error happened.
    But now it works because the WIN32 macro has been added into the project file by Visual Studio, as you can see from the attached screenshot.
    So, it seems that the patch is no longer needed until WIN32 is defined somewhere.

    PS: I just read that you too were able to compile successfully with Visual Studio. Great!

     
  • gpz

    gpz - 2025-12-01

    ok, i am closing this :) (you might still want to notice the opencbm guys)

     
  • gpz

    gpz - 2025-12-01
    • status: open --> wont-fix
    • assigned_to: gpz
     

Log in to post a comment.

MongoDB Logo MongoDB