mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
93 stars 70 forks source link

Address competition warnings fix in integer tests #182

Closed BoskyWSMFN closed 5 months ago

BoskyWSMFN commented 5 months ago

I'll try to fix #102 later.

mouse07410 commented 5 months ago

First, thank you!

Second - it looks like my Xcode toolchain now sees a different (albeit similar ;) problem:

  CC       check-INTEGER.o
check-INTEGER.c:175:3: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'int64_t' (aka 'long long') [-Wformat]
                rint64, ret, check_i64, check_ret);
                ^~~~~~
check-INTEGER.c:175:16: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'int64_t' (aka 'long long') [-Wformat]
                rint64, ret, check_i64, check_ret);
                             ^~~~~~~~~
check-INTEGER.c:177:44: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'int64_t' (aka 'long long') [-Wformat]
        printf("%"ASN_PRIdMAX" %"ASN_PRIdMAX"\n", rint64, check_i64);
                ~~~~~~~~~~~~~                     ^~~~~~
check-INTEGER.c:177:52: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'int64_t' (aka 'long long') [-Wformat]
        printf("%"ASN_PRIdMAX" %"ASN_PRIdMAX"\n", rint64, check_i64);
                               ~~~~~~~~~~~~~              ^~~~~~~~~
check-INTEGER.c:199:59: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'int64_t' (aka 'long long') [-Wformat]
        ret = snprintf(verify, sizeof(verify), "%"ASN_PRIdMAX"", check_i64);
                                                ~~~~~~~~~~~~~    ^~~~~~~~~
check-INTEGER.c:237:3: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                ruint64, ret, check_u64, check_ret);
                ^~~~~~~
check-INTEGER.c:237:17: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                ruint64, ret, check_u64, check_ret);
                              ^~~~~~~~~
check-INTEGER.c:267:59: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
        ret = snprintf(verify, sizeof(verify), "%"ASN_PRIuMAX"", check_u64);
                                                ~~~~~~~~~~~~~    ^~~~~~~~~
8 warnings generated.

What do you think would be the consequences of re-defining those variables as intmax_t and uintmax_t correspondingly?

BoskyWSMFN commented 5 months ago

I wouldn't do it for now. Based on the code in GNU C /usr/include/stdint.h, intmax_t and uintmax_t have different sizes depending on __WORDSIZE. Using (u)intmax_t instead of (u)int64_t may have unforeseen consequences. I'll come up with something else.

/* Largest integral types.  */
#if __WORDSIZE == 64
typedef long int                intmax_t;
typedef unsigned long int       uintmax_t;
#else
__extension__
typedef long long int           intmax_t;
__extension__
typedef unsigned long long int  uintmax_t;
#end