New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for building with IAR toolchain #1639
Commits on Sep 12, 2022
-
IAR declares strncasecmp in string.h not strings.h
strings.h is not an ISO header file, so IAR generates fatal error Pe1696 'cannot open source file "strings.h"'. Even though strncasecmp isn't an ISO C library function, IAR's runtime library defines it, though it declares it in string.h instead.
Ben Avison committedSep 12, 2022 -
[rp2040] Remove non-portable return statements
IAR generates error Pe118 'a void function may not return a value'.
Ben Avison committedSep 12, 2022 -
[rp2040] Explicit cast value of
hw_set_alias
Some compilers don't support the GNU extension `typeof` so their definitions of `hw_set_alias` can't inherit their type from their argument, and the best we can do is have `hw_set_alias` act the same as `hw_set_alias_untyped`. This requires an explicit cast when the macro is used instead, otherwise IAR generates error Pe132 'expression must have pointer-to-struct-or-union type but it has type "void *"'. The same goes for `hw_clear_alias`.
Ben Avison committedSep 12, 2022
Commits on Sep 13, 2022
-
Refactor pointer arithmetic on void*
This is a GCC extension, illegal in ISO C. IAR generates errors Pa152 'these operand types cannot be used here' and Pe852 'expression must be a pointer to a complete object type'. Replace with uint8_t*.
Ben Avison committedSep 13, 2022 -
IAR generates warning Pe111 'statement is unreachable'. In a couple of cases, replace return statements with TU_ATTR_FALLTHROUGH; because some compilers apparently can't figure out that the return statements are unreachable but do whinge about an imagined fall-through without them!
Ben Avison committedSep 13, 2022 -
Don't assume ints automatically convert to enums
IAR generates warning Pe188 'enumerated type mixed with another type'.
Ben Avison committedSep 13, 2022 -
Don't assume different enum types can be combined
IAR generates warning Pa089 'enumerated type mixed with another enumerated type'.
Ben Avison committedSep 13, 2022 -
This affects struct rspMsg in usbtmc_app.c (unconditionally) and uint8_t termChar in usbtmc_device.c (when NDEBUG is defined). IAR generates warning Pe550 'variable was set but never used'.
Ben Avison committedSep 13, 2022 -
Move variable into its own curly-brace scope
IAR generates warning Pe546 'transfer of control bypasses initialization of variable "invInvTag"'.
Ben Avison committedSep 13, 2022 -
IAR doesn't support __attribute__((fallthrough))
IAR generates warning Pa167 'the "fallthrough" attribute is not supported'. It doesn't generate warnings when one switch case falls through to another, so simply make TU_ATTR_FALLTHROUGH expand to an empty string. Also replace one instance of __attribute__ with the macro.
Ben Avison committedSep 13, 2022 -
[rp2040] Wrap GCC pragmas in #ifdef __GNUC__
IAR generates warning Pe161 'unrecognized #pragma'.
Ben Avison committedSep 13, 2022