mamedev / mame

MAME
https://www.mamedev.org/
Other
7.95k stars 1.98k forks source link

Visual Studio 2022 compilation errors #10488

Closed firewave closed 1 year ago

firewave commented 1 year ago

I ran make vs2019, opened it with Visual Studio 2022, performed the conversion and did a Release|x64 build. I am using the mame0249 tag and Windows 10.

2>S:\GitHub\mame\src\mame\sony\news_r4k.cpp(447,73): error C2672: 'devcb_write<int,1>::binder::set': no matching overloaded function found
2>S:\GitHub\mame\src\mame\sony\news_r4k.cpp(447,73): error C2672:   m_sonic3->irq_out().set(FUNC(news_r4k_state::irq_w<irq0_number::SONIC>));
2>S:\GitHub\mame\src\mame\sony\news_r4k.cpp(447,73): error C2672:                                                                          ^
[..]
2>S:\GitHub\mame\src\mame\sony\news_r4k.cpp(482,57): error C2672: 'devcb_write<int,1>::binder::set': no matching overloaded function found
2>S:\GitHub\mame\src\mame\sony\news_r4k.cpp(482,57): error C2672:   m_dmac->irq_out().set(FUNC(news_r4k_state::irq_w<DMAC>));
2>S:\GitHub\mame\src\mame\sony\news_r4k.cpp(482,57): error C2672:                                                          ^
3>S:\GitHub\mame\src\mame\sinclair\tsconf_m.cpp(714,9): error C2220: the following warning is treated as an error
[...]
3>S:\GitHub\mame\src\mame\sinclair\tsconf_m.cpp(714,9): warning C4806: '|': unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant
3>S:\GitHub\mame\src\mame\sinclair\tsconf_m.cpp(714,9): warning C4806:  return 0x02 | !m_sdcard->get_card_present();
3>S:\GitHub\mame\src\mame\sinclair\tsconf_m.cpp(714,9): warning C4806:         ^
2>S:\GitHub\mame\src\devices\cpu\tms57002\tms57002.h(209,10): fatal  error C1083: Cannot open include file: '../../emu/cpu/tms57002/tms57002.hxx': No such file or directory
2>S:\GitHub\mame\src\devices\cpu\tms57002\tms57002.h(209,10): fatal  error C1083: #include "../../emu/cpu/tms57002/tms57002.hxx"
2>S:\GitHub\mame\src\devices\cpu\tms57002\tms57002.h(209,10): fatal  error C1083:          ^

See #5741 and #4771.

dvk_kcgd.cpp

1>S:\GitHub\mame\src\emu\xtal.h(56): error C2220: the following warning is treated as an error
1>S:\GitHub\mame\src\emu\xtal.h(56): warning C4723: potential divide by 0
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(953,1): error C2446: ':': no conversion from 'device_finder<cpu_device,false>' to 'device_finder<cpu_device,true>'
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(953,1): error C2446:  auto cpu = (Side == SUB) ? m_maincpu : m_subcpu;
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(953,1): error C2446: ^
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(953,41): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(953,41): message :    auto cpu = (Side == SUB) ? m_maincpu : m_subcpu;
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(953,41): message :                                           ^
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(963): message : see reference to function template instantiation 'void `anonymous-namespace'::vs_dual_state::vsdual_vrom_banking<`anonymous-namespace'::vs_base_state::MAIN>(osd::u8)' being compiled
55>S:\GitHub\mame\src\mame\nintendo\vsnes.cpp(963): message :   m_maincpu->space(AS_PROGRAM).install_write_handler(0x4016, 0x4016, write8smo_delegate(*this, FUNC(vs_dual_state::vsdual_vrom_banking<MAIN>)));
8>S:\GitHub\mame\src\devices\bus\gameboy\gbslot.cpp(1234): error C2220: the following warning is treated as an error
8>S:\GitHub\mame\src\devices\bus\gameboy\gbslot.cpp(1234): warning C4701: potentially uninitialized local variable 'offset' used
8>S:\GitHub\mame\src\devices\bus\coco\cococart.cpp(608): error C2220: the following warning is treated as an error
8>S:\GitHub\mame\src\devices\bus\coco\cococart.cpp(608): warning C4701: potentially uninitialized local variable 'read_length' used
5>S:\GitHub\mame\src\frontend\mame\ui\icorender.cpp(220): error C2220: the following warning is treated as an error
5>S:\GitHub\mame\src\frontend\mame\ui\icorender.cpp(220): warning C4701: potentially uninitialized local variable 'actual' used
5>S:\GitHub\mame\src\frontend\mame\ui\icorender.cpp(225): warning C4701: potentially uninitialized local variable 'header' used
5>S:\GitHub\mame\src\frontend\mame\ui\icorender.cpp(187): warning C4701: potentially uninitialized local variable 'actual' used
4>S:\GitHub\mame\src\devices\cpu\v60\am1.hxx(1089,22): error C2220: the following warning is treated as an error
4>S:\GitHub\mame\src\devices\cpu\v60\am1.hxx(1089,22): warning C4646: function declared with 'noreturn' has non-void return type
4>S:\GitHub\mame\src\devices\cpu\v60\am1.hxx(1089,22): warning C4646: uint32_t v60_device::am1Error1()
4>S:\GitHub\mame\src\devices\cpu\v60\am1.hxx(1089,22): warning C4646:                      ^ (compiling source file ..\..\..\..\..\src\devices\cpu\v60\v60.cpp)

There's a lot of these - those are just stupid as they cannot even be fixed by adding a return...

xaudio2_sound.cpp

6>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\xaudio2.h(20,1): fatal  error C1189: #error:  "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from XAudio2Redist with applications that target Windows 7. See https://aka.ms/xaudio2redist."
6>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\xaudio2.h(20,1): fatal  error C1189: #error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from XAudio2Redist with applications that target Windows 7. See https://aka.ms/xaudio2redist."
6>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\xaudio2.h(20,1): fatal  error C1189: ^ (compiling source file ..\..\..\..\..\src\osd\modules\sound\xaudio2_sound.cpp)

See #9968.

4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(804,8): error C2668: 'signbit': ambiguous call to overloaded function
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(804,8): error C2668:                if (curr_delta == 0 || std::signbit(old_delta) != std::signbit(curr_delta))
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(804,8): error C2668:                   ^
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(309,32): message : could be 'bool signbit(float) noexcept'
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(309,32): message :     _Check_return_ inline bool signbit(_In_ float _X) throw()
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(309,32): message :                                ^ (compiling source file ..\..\..\..\..\src\devices\machine\ldv4200hle.cpp)
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(314,32): message : or       'bool signbit(double) noexcept'
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(314,32): message :     _Check_return_ inline bool signbit(_In_ double _X) throw()
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(314,32): message :                                ^ (compiling source file ..\..\..\..\..\src\devices\machine\ldv4200hle.cpp)
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(319,32): message : or       'bool signbit(long double) noexcept'
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(319,32): message :     _Check_return_ inline bool signbit(_In_ long double _X) throw()
4>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\corecrt_math.h(319,32): message :                                ^ (compiling source file ..\..\..\..\..\src\devices\machine\ldv4200hle.cpp)
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(804,8): message : while trying to match the argument list '(int32_t)'
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(804,8): message :               if (curr_delta == 0 || std::signbit(old_delta) != std::signbit(curr_delta))
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(804,8): message :                  ^
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(922,7): error C2668: 'signbit': ambiguous call to overloaded function
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(922,7): error C2668:            if (std::signbit(curr_delta) != std::signbit(next_delta))
4>S:\GitHub\mame\src\devices\machine\ldv4200hle.cpp(922,7): error C2668:               ^
4>S:\GitHub\mame\src\devices\machine\spg110_video.cpp(674,2): error C2220: the following warning is treated as an error
4>S:\GitHub\mame\src\devices\machine\spg110_video.cpp(674,2): warning C4305: 'initializing': truncation from 'double' to 'float'
4>S:\GitHub\mame\src\devices\machine\spg110_video.cpp(674,2): warning C4305:    };
4>S:\GitHub\mame\src\devices\machine\spg110_video.cpp(674,2): warning C4305:    ^
1>S:\GitHub\mame\src\devices\bus\epson_qx\keyboard\keyboard.cpp(115,12): error C3861: 'I8049': identifier not found
1>S:\GitHub\mame\src\devices\bus\epson_qx\keyboard\keyboard.cpp(115,12): error C3861:   auto &mcu(I8049(config, "mcu", 11_MHz_XTAL));
1>S:\GitHub\mame\src\devices\bus\epson_qx\keyboard\keyboard.cpp(115,12): error C3861:             ^
firewave commented 1 year ago

There's also a linker errors ...

2>ymfm.lib(ymfm_opn.obj) : error LNK2038: mismatch detected for 'annotate_string': value '1' doesn't match value '0' in mame.obj
2>ymfm.lib(ymfm_opn.obj) : error LNK2038: mismatch detected for 'annotate_vector': value '1' doesn't match value '0' in mame.obj
2>ymfm.lib(ymfm_adpcm.obj) : error LNK2038: mismatch detected for 'annotate_string': value '1' doesn't match value '0' in mame.obj
2>ymfm.lib(ymfm_adpcm.obj) : error LNK2038: mismatch detected for 'annotate_vector': value '1' doesn't match value '0' in mame.obj
2>ymfm.lib(ymfm_ssg.obj) : error LNK2038: mismatch detected for 'annotate_string': value '1' doesn't match value '0' in mame.obj
2>ymfm.lib(ymfm_ssg.obj) : error LNK2038: mismatch detected for 'annotate_vector': value '1' doesn't match value '0' in mame.obj

Edit: These are caused by me not enabling ASAN completely (actually multi-selected projects not applying settings) - see: https://learn.microsoft.com/en-us/cpp/sanitizers/error-container-overflow

cuavas commented 1 year ago

We don’t actually support building with VS2022 – there are too many compiler regressions. Note that only VS2019 is mentioned here: https://docs.mamedev.org/initialsetup/compilingmame.html#building-with-microsoft-visual-studio

Three of the things are addressed in ae24a68f0d7f610fdb975fd3626f622fd0bdd642. The others are issues with MSVC itself. As usual, the response is that we don’t pander to broken toolchains.

ajrhacker commented 1 year ago

The integer overloads of std::signbit might not be part of the C++ standard, despite what cppreference.com claims. See https://bugs.launchpad.net/kicad/+bug/1742803.

firewave commented 1 year ago

Thanks a lot for the analysis and the fixes.

I added an additional error after my initial post which you have missed though. It's the last one about the missing I8049. That's one I don't understand at all. It's like an include is missing...

Some of the warnings might also pop up with Clang (they look quite familiar) but are warnings which are disabled by default.

  • Fourth error is legitimate, but you really need to provide more context. I needed to work out the full source file path and to go through all uses of crystal frequencies in the file to work out where it come from.

That's all the info Visual Studio gives - which also is a bug IMO. I took a look and it seemed like some device was giving a 0 clock but apparently it was something different.

I didn't run into these the last time I compiled it but that's been a while now. Also it included some errors which cannot be "configured away" so I thought the build had regressed in recent versions and just provided all of them - even if known.

I didn't think to look for a "known issue" section since there's no reference in the build guide. Me not thinking that was the paragraph after the VS build is about shortcomings of MSYS2 but there is none about VS. That comes later on in the "Known issues" section. I think there should maybe a reference to the section from the build sections and this additional MSYS2 paragraph should be moved there and moved closer to the previous one. That might make it a bit clearer.

There's a linker error after all:

358>portaudio.lib(pa_win_wdmks.obj) : error LNK2005: KSDATAFORMAT_SUBTYPE_MIDI already defined in dxguid.lib(dxguid.obj)

But that is already implicitly covered in https://github.com/mamedev/mame/issues/9968#issuecomment-1172054361 and the documentation.

The integer overloads of std::signbit might not be part of the C++ standard, despite what cppreference.com claims. See https://bugs.launchpad.net/kicad/+bug/1742803.

See also https://github.com/microsoft/STL/issues/519.

firewave commented 1 year ago

I added an additional error after my initial post which you have missed though. It's the last one about the missing I8049. That's one I don't understand at all. It's like an include is missing...

Nevermind - that's #10482.

pmackinlay commented 1 year ago

For posterity, I've reported the first issue mentioned above here.