This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

#169-D argument of type "uint8_t *" is incompatible with parameter of type "BYTE *

I have defined the type BYTE as follows:

typedef char BYTE;

uint8_t is defined in stdint.h as follows:

typedef unsigned char  uint8_t;

In Project properties -> Build -> ARM Compiler -> Advanced options -> Runtime Model options:

  • "Chars signed by default" is unchecked
  • "Specify how to treat plain chars" is set to "Unsigned"

Can somebody explain to me why I get this compiler warning?

How can I avoid it?

Bye

Mario

 

  • It's important to keep in mind that in C, the three types "char", "unsigned char", and "signed char" are all distinct types, even though "char" has the same format as one of "unsigned char" or "signed char." You can freely assign between these types, because the language allows implicit conversion between arithmetic types. However, the language does not allow implicit conversion between pointers of different types.

    I assume you intend to use the typedef BYTE to do byte-wise access of larger objects. In that case, you should define it as "unsigned char," because the standard guarantees you can do this with "unsigned char", but does not necessarily guarantee you can do it with "signed char" or "char."
  • Thank you for the prompt reply.

    In my 25 years of C language programming, I have used many compilers and many development systems, and I know that almost all of them don't give warnings on pointers to different (but actually same) types.

    This issue is very heavy when integrating various open-source modules from different developers. I would not be forced to replace all user-defined types in a module to avoid warnings on BYTE * to unsigned char * conversions.

    A compiler switch to skip this warning would be appreciated.

    Please let me know your considerations.

    Thanks

    Mario

  • selene58944 said:
    A compiler switch to skip this warning would be appreciated.

    You can either use the command line option --diag_suppress=169 or, in the source, the #pragma diag_suppress 169.  For details see the slides titled Diagnostic in the ARM compiler tips & tricks presentation.

    Thanks and regards,

    -George