Why does the compiler complain about the inconsistent argument type "char" and the conversion specifier "s" in the following printf file?
#include <stdio.h>
#include <stdlib.h>
typedef char * STR;
int main(void) {
struct MyStruct {
STR str;
};
struct MyStruct ms = {"some text"};
printf("%s\n", ms.str);
return (EXIT_SUCCESS);
}
The compiler has no complaint about the same code when deleting a typedef:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
struct MyStruct {
char * str;
};
struct MyStruct ms = {"some text"};
printf("%s\n", ms.str);
return (EXIT_SUCCESS);
}
Notes:
System = Win 64, NetBeans IDE 8.2, GCC compiler, no diff, regardless of whether the tools use Cygwin or MinGW or 32 or 64 bits.
The error is resolved if I avoid either a structure or a typedef. But an error is present whenever both typedef and struct are used, as shown.
( ) stackoverflow.com/questions/20944784/, . , , typedef
char (typedef char const * STR);
char (typedef char * const STR);
char (typedef char const * const STR);
Verbatim: "char" "s".
, ms.str - char * (, sizeof, "c" char, , , char char ..)
typedef (, STR STR_TEST) . , .