marc@ima.ISC.COM (Marc Evans) (02/11/88)
While hacking with some source the other day, I discovered some strangeness in dbx given a couple different variations of the following program: main() { static struct foo_t { char *a,*b; } foo[] = { "foo", "bar", "hello", "world", "what's", "up", }; printf("%s %s\n",foo[1].a,foo[2].b); } This program compiles and runs fine on my Ultrix 2.0 system using /bin/cc. The problem that exists is when using dbx. Try usign dbx and stoping at the printf line, then do a 'print foo'. On my system, I get a dump of a bunch of octal (-1)'s. A subtle change of moving the structure outside of the function to the module level, produces the same results. The interresting part is that if after moving the structure to the module level, then removing the 'static' from the declaration, dbx does the *proper* thing when requesting 'print foo'. Is this normal for dbx, or is it just an Ultrix problem.
jackm@devvax.JPL.NASA.GOV (Jack Morrison) (02/12/88)
In article <881@ima.ISC.COM> marc@symetrx.UUCP writes: >While hacking with some source the other day, I discovered some strangeness >in dbx given a couple different variations of the following program: > >main() >{ > static struct foo_t { char *a,*b; } foo[] = { > "foo", "bar", > "hello", "world", > "what's", "up", > }; > printf("%s %s\n",foo[1].a,foo[2].b); >} > Sorry to post, but mail address was not known. Did you try declaring foo[] correctly, as in static struct foo_t { char *a,*b; } foo[] = { { "foo", "bar" }, { "hello", "world" }, { "what's", "up" } }; ??? Many compilers won't accept it the way you've shown. What that has to do with dbx, though... -- Jack C. Morrison Jet Propulsion Laboratory (818)354-1431 jackm@jpl-devvax.jpl.nasa.gov "The paycheck is part government property, but the opinions are all mine."