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

Visual Studio 2022 compilation errors #10488

Closed
firewave opened this issue Oct 31, 2022 · 6 comments
Closed

Visual Studio 2022 compilation errors #10488

firewave opened this issue Oct 31, 2022 · 6 comments

Comments

@firewave
Copy link
Contributor

firewave commented Oct 31, 2022

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 firewave changed the title Visual Studio 2022 compilation errors Visual Studio 2022 compilation/linker errors Oct 31, 2022
@firewave
Copy link
Contributor Author

firewave commented Oct 31, 2022

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

@firewave firewave changed the title Visual Studio 2022 compilation/linker errors Visual Studio 2022 compilation errors Oct 31, 2022
cuavas added a commit that referenced this issue Nov 1, 2022
Also worked around a couple of MSVC warnings reported in #10488.
@cuavas
Copy link
Member

cuavas commented Nov 1, 2022

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

  • The first error is a bug in MSVC. Please take it up with Microsoft.
  • The second error is kind of stupid, but harmless to work around. It’s giving a useless message for an implicit bool-to-int promotion.
  • Third error is a side-effect of GENie not being able to detect downstream dependencies of generated headers. It won’t be fixed until we replace GENie with CMake.
  • 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.
  • Fifth error seems like a compiler bug with not considering implicit cast operators. Both device finders can be cast to cpu_device *, providing a common type for the conditional expression. I can work around it, but please take up the issue with Microsoft – it’s going to cause a lot of pain for a lot of people.
  • Sixth error is a case of MSVC not being able to do static code flow analysis properly. There’s no way to reach line 1215 in a state where gbxregion is non-null but offset is unset, so offset will always be set when reaching line 1230. Initialising variables to stop MSVC reporting this warning hides real bugs where a path is created that allows a variable to be used with no meaningful value set that could otherwise be detected with Coverity and Valgrind. You need to set NOWERROR=1 to build with MSVC due to these spurious warnings.
  • Seventh and eighth errors are the same as the sixth error.
  • Ninth error seems like a warning created by a person who doesn’t know about function pointers. I see no reason to enable that warning.
  • The solution to the tenth error is described in detail on [MSVC] fatal error C1189: #error: "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions." #9968, and also mentioned here. I don’t know why you’re reporting it as a bug when it’s a configuration issue on your side.
  • Eleventh and twelfth errors seem to be another manifestation of the first error, not considering implicit conversions properly – take it up with Microsoft.
  • Thirteenth error seems stupid – are they expecting every initialisation of a float with a literal to have an F suffix? We aren’t adding F suffixes to all the numbers in that massive table – that would be far too much unnecessary clutter, making already overly long lines even longer and harder to read.

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

@cuavas cuavas closed this as completed Nov 1, 2022
@ajrhacker
Copy link
Contributor

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
Copy link
Contributor Author

firewave commented Nov 1, 2022

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 #9968 (comment) 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 microsoft/STL#519.

@firewave
Copy link
Contributor Author

firewave commented Nov 1, 2022

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
Copy link
Contributor

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

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

4 participants