WMM audio driverdoes not build with MSVC
Versatile Commodore Emulator
Brought to you by:
blackystardust,
gpz
I got an error when building vice\src\sounddrv\soundwmm.c with VisualStudio.
Before including system files like windows.h, the code does this strange thing:
#if __GNUC__>2 || (__GNUC__==2 && __GNUC_MINOR__>=91)
MSVC does not define GCC macro (obviously), but actually I have to say that I don't undestand very well the reason because it does that.
If I remember well, in the 1993 GCC-2.x was able to provide a preliminar support for Windows by combining DJGPP and RSXNT,
However, in my opinion, it would be better to remove this #if...#endif.
Afterall, since you are using with "-std=c++11", this ancient compiler will never work and after that change it will make this source file compatible with MSVC.
DJGPP and RSXNT, yes; Visual C, no. It wasn't until GCC 2.91 that MinGW's headers looked enough like Visual C's headers that "soundwmm.c" could be built by both Microsoft's and GNU's compilers. I think that there used to be MSVC version tests there, too. But, official support for Visual C was removed from VICE.
I agree, that preprocessor line has been obsolete for a long, long time.
(
-std=c99is used for C source files.)Thank you for the quick reply.
I understand that MSVC is not supported, but probably I used wrong words or I did not explained well what I was thinking, sorry.
This is the piece of code:
Later, the source code uses functions and types provided by the system includes, like HANDLE, WAVEFORMATEX and so on. And it uses them unconditionally.
If windows.h and mmsystem.h are not included, who will provide these types and functions?
If you have a compiler that does not satisfy the tests on GNUC macro, for example an older value, or you try to build with an incomplete environment, the presence of those tests doesn't matter because the compilation will always break with errors and it won't work.
This is why I have written that "I don't undestand very well the reason", because in my opinion that #if...#endif is a nonsense, indipendently by the fact that you are using RSXNT, MinGW, LCC, OpenWatcom or others.
Thank you very much for your time.
Sincerely.
What version of VICE is this? I’m guessing not the latest if you are using Visual Studio?
Best Regards,
Dave
Last edit: gpz 2020-10-12
I'm using latest sources from SVN.
1) I created a project, I attached all sources and I selected the ones that should be compiled for the x64sc platform.
2) Then I copied into the directory of the project some files generated by the MinGW build, like config.h for example.
3) I commented into config.h few functions that I have not in MSVC.
4) Compile/link (~ 1 minute) and play.
When I did the very first build try, I also fixed 2 or 3 errors and few warnings (I think that it would be useful to fix them also into current trunk). But those corrections were quite easy, hopefully.
So, in short, at the time of writing the SVN sources can be compiled into MSVC without big troubles.
Interesting. I agree the ifdef is pointless, i have removed it in r38799. Infact ALL of those checks for specific compilers (including GCC) should be removed. It's all a bit pointless these days :)
As for compiling in MSVC - i wouldnt mind including a step by step HOWTO in the next release if someone writes it :=) perhaps the cmake script in the repo can also be useful for this?
Thanks, it's fixed.
About MSVC, I would like to add that VICE also compiles with the ancient version 6.0.
Except 3 or 4 sources that need few fixes in the declaration of some variables, like this one:
the 99.99% of the sources are clean C90 code and it worked fine.
In this example, I had to move the declaration of "kbd_status" because, as you know, C90 does not allow to declare variables "where you want".
Instead, more recent versions of Visual Studio can do it hopefully. ;)
please make another ticket and report those things - our styleguide does not allow this either, so it should get fixed :)