ac> Hi there. Why does emx/gcc disallow the modification of string constants?
Presumably so that they can be stored in the same area of memory
as the program code, and be protected. I don't know. The ANSI
Rationale is available from here if you want to see if they
said anything about that.
ac> Or more to the point - why does ANSI/ISO C disallow this? Tnx.
From memory, they made it implementation-defined whether you could
or not.
ac> 1.0, the following code executes without error. CLint 1.41 also passed the
ac> following code with flying colors.
I would imagine it would be hard for lint to detect something
like that.
ac> The following code is a simple work-around for the rule:
ac> char *str = strdup("Hello world");
Bearing in mind that strdup() is not ISO C. A better method
would be char str[] = "Hello world";
BFN. Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|