Erik de Castro Lopo
2017-Jan-15 01:23 UTC
[flac-dev] unsigned int and FLAC__uint32 are used interchangeably
lvqcl wrote:> Also MSVC fails because src/libFLAC/include/private/bitmath.h now > contains "uint32_t long idx" instead of "unsigned long idx".Ah, missed that because it was MSVC code. They should be `uint64_t`.> According to MSDN _BitScanReverse*() functions have signatures: > unsigned char _BitScanReverse(unsigned long *, unsigned long); > unsigned char _BitScanReverse64(unsigned long *, unsigned __int64);The `unsigned long` type should be synonymous with `uint64_t` so using `uint64_t` should be safe. Furthermore if they aren't synonymous we *want* that to be a compile error!> Other than that, it compiles everything without errors.Thanks! Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
Dave Yeo
2017-Jan-15 03:16 UTC
[flac-dev] unsigned int and FLAC__uint32 are used interchangeably
On 01/14/17 05:23 PM, Erik de Castro Lopo wrote:> The `unsigned long` type should be synonymous with `uint64_t` so using > `uint64_t` should be safe. Furthermore if they aren't synonymous we > *want* that to be a compile error!DOSish systems seem to use long for 32bit types and long long for 64 bit types, at least when targeting 16 bit (int is 16 bit) or 32 bit (int is 32 bits) systems. Long would be 64bits on a 64 bit system. Best to just stay with the *_t types. Dave
lvqcl
2017-Jan-15 05:00 UTC
[flac-dev] unsigned int and FLAC__uint32 are used interchangeably
Erik de Castro Lopo wrote:>> Also MSVC fails because src/libFLAC/include/private/bitmath.h now >> contains "uint32_t long idx" instead of "unsigned long idx". > > Ah, missed that because it was MSVC code. They should be `uint64_t`.No, sizeof(unsigned long) is always 4 on Windows. See http://www.viva64.com/en/t/0012/>> According to MSDN _BitScanReverse*() functions have signatures: >> unsigned char _BitScanReverse(unsigned long *, unsigned long); >> unsigned char _BitScanReverse64(unsigned long *, unsigned __int64); > > The `unsigned long` type should be synonymous with `uint64_t` so using > `uint64_t` should be safe. Furthermore if they aren't synonymous we > *want* that to be a compile error!It's synonymous to uint32_t, but if the 1st parameter for _BitScanReverse*() functions has 'pointer to unsigned long' type then IMHO it's better to simply use unsigned long variable there.
Erik de Castro Lopo
2017-Jan-15 05:29 UTC
[flac-dev] unsigned int and FLAC__uint32 are used interchangeably
lvqcl wrote:> > Ah, missed that because it was MSVC code. They should be `uint64_t`. > > No, sizeof(unsigned long) is always 4 on Windows. > See http://www.viva64.com/en/t/0012/Bah! Trust Windows to be different :).> >> According to MSDN _BitScanReverse*() functions have signatures: > >> unsigned char _BitScanReverse(unsigned long *, unsigned long); > >> unsigned char _BitScanReverse64(unsigned long *, unsigned __int64); > > > > The `unsigned long` type should be synonymous with `uint64_t` so using > > `uint64_t` should be safe. Furthermore if they aren't synonymous we > > *want* that to be a compile error! > > It's synonymous to uint32_t, but if the 1st parameter for > _BitScanReverse*() > functions has 'pointer to unsigned long' type then IMHO it's better to > simply use unsigned long variable there.Sorry, I disagree on the idea of using `unsigned long` exactly because anyone that comes from Unix will assume that is `uint64_t`. Better to use `uint32_t` which is totally platform independant and unambiguous. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/