On Sep 20, 2005, at 5:43 AM, lbland wrote: hi-
I'm using xCode 2.1 and have a statement like this:
static *char myStringArray[] = {"a", "b", "c", (char *)0};
when I use gdb and look at the addresses of the elements of the array they are something like 0x1 to 0xa (invalid memory). Same when I print them out (not using gdb). It seems like the file scope constant sections are not assigned properly (maybe not realigned right). Strange that other similar lines in other .o files in the executable execute right, it is just one .o file that is causing problems.
Has anyone seen this issue in xCode 2.1 (on PPC).
That doesn't look like a valid declaration to me - the * is in the wrong spot, isn't it? Anyway, when I try this with a properly-declared array, I get the expected results (see below). You'll have to provide some more detail in order to track this down. I suggest filing a bug report at http://bugreporter.apple.com with a minimal project that shows the problem.
With this program: #include <stdio.h> static char *myStringArray[] = {"a", "b", "c", (char *)0};
int main (int argc, const char * argv[]) { int x;
for (x=0; x<4; x++) { printf("%s\n", myStringArray[x]); } return 0; }
The output I get looks like this. a b c (null)
|