sarah-walker-pcem / pcem

PCem
http://pcem-emulator.co.uk
GNU General Public License v2.0
1.52k stars 208 forks source link

Fix bug discovered by MSVC. #153

Closed MarekKnapek closed 2 years ago

MarekKnapek commented 2 years ago

error C2078: too many initializers

michael-manley commented 2 years ago

May I ask how you got this remotely buildable on MSVC? maybe for a future guide for people who want to compile that way?

MarekKnapek commented 2 years ago

Yeah, ... I don't know. I just discovered a year old version of PCem on my laptop. I don't remember what I did back then. Today I wanted to resurrect it and I remembered the bug. I'm myself a Windows boi (and Visual Studio IDE boi) and it is very hard for me to use dependencies via CMake. If I figure it out one day, I will sure let you know.

MarekKnapek commented 1 year ago

Hi @michael-manley as promised I'm back. I know how to build pcem by Visual Studio's compiler. I don't know if this is the right place to discuss it. Or should I create new issue, wiki page, IRC, discord or whatever? Anyway, the tutorial how to do it is located on my branch at https://github.com/MarekKnapek/pcem/blob/msvcdocs/msvc/msvc.md plus I needed to make some code changes. These changes are solely for purposes to "make-compiler-to-stop-complaining" and I didn't care if they are according to code style or even correct at all. The changes are mostly about 1) global variables being declared vs defined in C vs in C++ vs in C header included form C++ source. 2) pre-processor macros about detecting compilation for x86 or x64. 3) One instance of typo in uint64_t. 4) Type off64_t is in POSIX but not in C. 5) M_PI is not standard. 6) I disabled inline assembly, this is definitely not correct (but hey, it didn't crash on me at run-time). 7) Attribute noinline. 8) pragma pack 9) strcasecmp vs stricmp 10) fopen64/fread64 and friends. 11) Variable len arrays. 12) And maybe more, I don't remeber now. The code changes are located on my branch at https://github.com/MarekKnapek/pcem/commits/msvc and I'm happy do discuss each change separately why I made it and why it was a problem (usually not conforming to C standard, but using gcc/posix extensions). In the end I'm able to run pcem compiled by MSVC in debug mode in both x86 and x64, I didn't try release and I tested just few minutes inside virtual bare bones MS-DOS 5.0 and DOS nor pcem didn't crash. Also, I disabled networking and plug-in support at compile time (at cmake time) as I didn't want to investigate compiler error messages, I wanted "at-least-something" compliable and able to run. Best regards, Marek.