Re: [hatari-devel] Switching from SDL_types.h to inttypes.h ? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi Nicolas,
On 28.9.2022 23.56, Eero Tamminen wrote:
On 28.9.2022 23.04, Nicolas Pomarède wrote:
Le 28/09/2022 à 20:00, Troed Sångberg a écrit :
I would be in favor of keeping them in those cases. When SDL gets
switched out in the future (or in a fork) you'd want to make sure you
revisit all affected code.
I would keep them too, who knows if later some compiler might not
complain if type is uint8_t instead of Uint8 for example in some SDL
functions prototypes.
C language has integer promotion as basic feature. That's not going to
change. I do not see any way to get compiler to check for these naming
mismatches, especially when the underlying types are *identical*.
Besides, C compiler does not provide warnings even if you use e.g.
uint8_t variable to provide SDL function Sint32 argument value.
If there were pointers to the types, that might matter, but as far as I
can see, SDL functions take pointers only to SDL's own struct types, not
to integers.
>
And it makes the code more explicit about the fact that it's related
to SDL in some ways.
Where you would draw the line? And considering automatic integer
promotion, how you could check for that?
Thomas already converted some of the files that use SDL_Swap*()
byte-endianess functions:
-----------------------------------------------
$ git grep -l SDL_Swap
src/avi_record.c
src/cpu/maccess.h
src/cpu/sysdeps.h
src/debug/symbols-common.c *
src/floppy.c *
src/hdc.c *
src/ide.c
src/lilo.c
src/msa.c *
src/screenConvert.c
src/sound.c *
src/tos.c *
src/video.c
src/wavFormat.c
tools/debugger/gst2ascii.c
tools/hmsa/floppy.c
-----------------------------------------------
To use stdint.h types instead (ones marked with '*').
Btw. Following files are using WinUAE functions from maccess.h, which
take uae_u* types and give them to SDL functions:
-----------------------------------------------
$ git grep -l -e do_put_mem_ -e do_get_mem_ -e do_byteswap_ | grep -v
src/cpu/
src/debug/68kDisass.c
src/gemdos.c
src/includes/ioMem.h
src/msa.c
src/stMemory.c
src/video.c
-----------------------------------------------
But only these use the intended uae_u* types:
-----------------------------------------------
$ git grep -l uae_u | grep -v src/cpu
src/ide.c
src/includes/ide.h
src/includes/ioMem.h
src/includes/m68000.h
src/includes/stMemory.h
src/ioMem.c
src/m68000.c
src/memorySnapShot.c
src/ncr5380.c
-----------------------------------------------
In case of WinUAE CPU core functions, using its own types could make
more sense, because unlike SDL ones, those functions are lacking a
prefix that could be used to easily find them all.
But I think Hatari is unlikely to change from WinUAE to something else,
so IMHO using C99 stdint.h types for those is fine too.
- Eero