Conversation
|
(which brings up another issue - I avoided %zu - which is not available on default mingw due to msvcrt.dll not being C99 and uses %Iu instead) |
include/internal/macro.h
Outdated
| */ | ||
| #define __is_constexpr(x) \ | ||
| (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) | ||
| (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * (uintptr_t)0l)) : (int *)(uintptr_t)8))) |
There was a problem hiding this comment.
Hmm... I think it’d be much better to only replace (long) with (intptr_t), and 0l with 0, so simply:
(sizeof(int) == sizeof(*(8 ? ((void *)((intptr_t)(x) * 0)) : (int *)8)))Rationale:
- The original code had signed integers, and there’s no need to unsign them now, is it?
- The problem, according to the compiler error message, only seems to be the combination
(void *)(long), so there’s no need to do anything about(int *)8, is it? - The
lin0lshould be unnecessary due the integer promotion rules mentioned in Remove global variables #66 (reply in thread). The reason that(long)(x) * (uintptr_t)0lis accepted by the compiler is, again, due to the integer promotion by the*operator. Given the operands(long) * (uintptr_t)this implicitly becomes the largest of the two types, so(uintptr_t) * (uintptr_t), hence having a(long)is quite dubious? Not to mention the problem of different signedness as well?
There was a problem hiding this comment.
Yes, it seems to make mingw happy:
(sizeof(int) == sizeof(*(8 ? ((void *)((intptr_t)(x) * 0l)) : (int *)8)))
or just 0 instead of 0l
Maybe we can define our own #if defined(__MINGW32__)
#define PRIuz "Iu"
#else
#define PRIuz "zu"
#endifso that, for example, printf("header size %zu\n", header_size);becomes printf("header size %" PRIuz "\n", header_size);? |
|
Regarding On Windows it depends on which libc variant you link with. And if you are using mingw, you can opt in to override printf() with mingw own: #define __USE_MINGW_ANSI_STDIO 1I only have minor experience due to providing windows build (using mingw) of Open Cubic Player, but do no other C programming on Windows. |
|
TOS/libc doesn’t have |
|
There you go: frno7/toslibc@4f93d3a |
|
I suggest we merge 5d21139, okay? |
|
My last update has compiletime workaround for systems lacking intptr_t |
Is there any known (and relevant) system that doesn’t have |
|
build-atari-st failed here on github in your CI, but probably before you modified toslibc. You decide ;) Your pet project |
Yeah, I added
Indeed, but it’s your commit. Merged in commit 5d21139, thanks! |
|
%zu and %zd appears to be present if c:\windows\system32\msvcrt.dll is from Visual Studio 2015 or newer (internal version 14), So Windows Vista with updates and beyond. Windows appear to maintain compatibility with their own %Iu and %Id still which was their alternative instead of implementing C99 prior to to this Visual Studio version. Use #ifdef _WIN32 and use %Id and %Iu if you want to be ultra-portable to old versions of Windows without updates (or 3rd party software installing "newer" Visual Studio runtime). The warnings mingw gcc throws out should be more informative :) |
|
What’s your preferred level of compatibility with Windows for Open Cubic Player? My preference for PSG play is to keep the code clean, so any workaround (for Windows or otherwise) needs some justification. My focus is Linux; maintaining some level of compatibility with BSDs and Mac OS is usually easy too. The Atari ST doesn’t use the PSG play library as such, but there are minor cases of shared source files (such as the macro definitions we saw yesterday). |
|
Windows support was added about 3 years ago, until that my fork/remake was unix systems only. Windows is the black sheep in the source code. Many things must be specially handled in Windows, and there are buggy API's that do not get fixed, since it will break earlier applications. So when easily possible I use what is backwards-compatible, and when that is a major hassle I only support newer versions until I get complaints I can can reconsider. |
|
@mywave82, what’s your plan or suggestion on the |
|
These are the most obvious options I think: Don't do anything, and the messages simply outputs %zu on old windows systems, and systems with old version of Visual C libraries installed. Add the #ifdef _WIN32 and use the Windows special variant, it still works on newer versions. Use %d or %u and typecast the result of sizeof(). Last option always works and is the least amount of clutter in the source code. |
|
Line 117 in c76403a and Lines 526 to 527 in c76403a Others found by grep are not part of the library, so should be safe. Moreover, diag_error only matters if SNDH tags are iterated with
psgplay/include/psgplay/sndh.h Lines 198 to 209 in c76403a (or |


Compiling with mingw produces MANY instances like this:
Verified with this small test program
Which produces this output (both without and with the fix)
on x86_64-w64-mingw32:
on x86_64_linux:
Same issue in lib/toslibc/include/internal/macro.h