Here is an example below where I try to assign a const pointer to a const pointer in the struct and the compiler won't let me. But I can assign a literal without any problem. I've also tried this case with out any const's and with some const's if you know what I mean, but I still don't see why the compiler is cool with the literals but as issues with the char* in the assignment.
const char* cat_surname = "Snack";
typedef struct
{
const char* first;
const char* last;
}PET_T;
PET_T dog =
{
"Rover", // OK
"Cateater" // OK
};
PET_T cat =
{
"Tasty", // OK
cat_surname // ERROR :-(
};
I get this compiler error:
error: initializer element is not constant
Using Arch Linux gcc version 4.8.2 20140206 (prerelease) (GCC)