7 Replies Latest reply on Mar 19, 2018 1:05 AM by SrikanthD_56

    printf with uint32_t gives strange error messages/warnings




      I'm using printf with a variable of type uint32_t. Variables of this type have a fixed with of 32 bits, so this equals to long int in C. Is this true?


      So, for printf, the correct format string is:

      printf("%lu", Var);     //%lu => long unsigned


      Now, it's getting strange: If I use %lu, I get no error in the notice list after a build, but a error indicator in the corresponding line of the source editor window, saying "format specifies type 'unsigned long', but the argument has type 'uint32_t' (aka 'unsigned int')".

      If I use %u, the error indicator in the source editor window wents away, but after a build a warning is shown in the notice list: "format '%u' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t {aka long unsigned int}"


      This is confusing. I know I can use

      printf("%lu", (long int)Var);

      which eliminates both error indicators, but I wonder why there are errors different positions (source code window vs. notice list), and why %lu gives an error - %lu should be right IMHO.

      Is the behaviour regarding the error messages a bug of PSoC Creator? Should I file a case about it?