captainys / TOWNSEMU

FM Towns Emulator "Tsugaru"
BSD 3-Clause "New" or "Revised" License
247 stars 18 forks source link

Workaround for clang-cl build #12

Closed pinterior closed 4 years ago

pinterior commented 4 years ago

Workaround for errors caused by clang-cl bug(?)

D:\work\TOWNSEMU\src\towns\memory\physmem.h(369,37): error : non-type template argument evaluates to -2147483648, which cannot be narrowed to type 'unsigned int' [-Wc++11-narrowing] TownsVRAMAccessTemplate <TOWNSADDR_VRAM0_BASE ,TOWNSADDR_VRAM0_END > VRAMAccess0;

I prefer integral types from <cstdint>, but respect current coding style.

captainys commented 4 years ago

Seriously? It looks to be an issue of clang as you mention. Actually I want to make townsdef.h eventually available to High-C by cplusplus macro so that towns-app sources can directly include this header in place for vmif.h. So, I want to avoid strongly-typed enum if possible. Are you able to get away from the errors if you use #define instead of enum?

captainys commented 4 years ago

By the way, I was not aware that stdint.h was in C99 standard. I thought I saw many open-source projects suffering from uintXX_t issues (multiple depending libraries declare own uintXX_t types) long after 2004, but apparently stdint.h existed after 2004. Replacing everything all at once will most likely will cause a disaster, but I'll gradually replace long long int to int64_t. Thanks!

captainys commented 4 years ago

Thanks! I take it.

pinterior commented 4 years ago

#define TOWNSADDR_VRAM0_BASE 0x80000000 works fine with clang-cl. On the other hand with C compiler, I think it's also safer to use #define because enum signedness is implementation-defined. (I cannot check High C behavior at this time, but HC17UM.DOC 8.5 does not mention on unsigned types.)