I heavily reduced my real code in order to make it as compact as possible for this posting.
My questions is about the const attribute. When I compile this ...
const char tmp[] = "anything";
int main(int argc, char *argv[]) {
/* my code */
return 0;
}
char *somefunction (char *c) {
extern const char tmp[];
/* my code */
return tmp;
}
... I get:
warning: return discards 'const' qualifier from pointer target type [enabled by default]
The code works fine.
The somefunction didn't touch the string tmp, so why does return generate this warning?
If I leave const away, the warning disappears.
char*and notconst char*. Changechar *somefunction (char *c)toconst char *somefunction (char *c)- Jabberwocky