Pass a uint32_t
to a function that requires uint64_t
: You can do this, and all compilers I know accept it, even in strict modes.
void MyFunction(uint64_t arg) {}
int main(void) {
uint32_t xyz = 1u;
MyFunction(xyz);
}
uintN_t
types are in the C standard library C99 and later.
Optional types uint32_t
and/or uint64_t
might not exist, yet that is only on very unusual machines. (E. g. CHAR_BIT == 9
)
Code is missing #include <stdint.h>
Is it safe to pass a
uint32_t
to a function which defines the input type asuint64_t
?
Yes. Yet see above notes.
Is it explicitly allowed by the standard?
Yes.
Is it safe?
Yes.
What does MISRA-C say about this?
Type sign-ness and value changes are things MISRA and well enabled compilers whine about.
A sign-ness/value change does not occur in OP's code.