At 02:44 AM 10/28/2003, Peter Greenhill wrote:
I am trying to use a globally defined static const char array in a shared
library. It is my understanding that read-only globals can be used in a
shared library. The library is around 27k & I'm compiling with CodeWarrior
9.2. When I define an array as, for example,
static const char* entities[] = {
  "this",  "is",
  "an",   "array" };
I get a link error "entities has illegal single segment 32-bit reference to
...". If I explicitly define the index expressions, the object links. How
can I define the array so as to not have to explicitly define the index
expressions?

This isn't a true read-only global, since an array of char pointers has to be modified at runtime to hold the correct pointer values.


You could say

static const char entities[][6] = {
  "this",  "is",
  "an",   "array" };

and have it work, but at the cost of paying for padding after the short words. Have you considered just making this a string list resource and compiling that with the library? If the word list is long enough, that would be a better approach.

P.S. Make sure the 68K processor panel has "PC-relative constant data" checked.

--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com



-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to