Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - string arrays in C

string arrays in C

Discuss topics that apply across the products, such as the PocketC language, or development in general

Postby izzy on Mon Jul 04, 2005 5:01 pm

Hi,

I'm pretty new at C, and I cannot figure this one out. I'm trying to write a PocketC library. I need to call a string array within a function (since I can't access globals in a library, I think). So I called it like this;
char *weekday[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
Now, when I access a single element, say;
StrCopy(c,weekday[i])
CodeWarrior will give me 7 (the amount of elements) link errors stating:
'@443' has illegal single segment 32-bit reference to '@436'
the next error will say the same but to '@437' and so forth.

Can anyone help me or direct me where I can get help?
izzy
 
Posts: 20
Joined: Fri Jun 11, 2004 1:48 pm

Postby mgreen on Mon Jul 04, 2005 5:29 pm

You have to look at the documentation "native.html" and the much too simple examples in the folder PocketCLib, both in the distribution files.

Typically, you have to pass a pointer to a string array to the function. In the native function, you have to dereference the pointer using the call-back functions (pop deref), index into the array and get the Pocket C string reference, then dereference the string pointer using another call-back function that locks the string in place (lockString), then be sure to unlock the string with another call-back function (unlockString) when you're finished with it.

I wrote an interface to BTPrint (a printing package) for PocketC in Palm Pascal that's available on their website. The interface does access single string values using the call-back functions.
-----
Michael Green
mgreen
 
Posts: 72
Joined: Fri Mar 14, 2003 9:40 pm
Location: USA

Postby izzy on Tue Jul 05, 2005 12:55 am

Thank you for answering.

I'm not sure you understood me. The string array is called and accessed inside the same library function, not in the PocketC code. It's not done with Values, but with a standard char* array. From what I understand, the PocketCLib API should not be called here.
izzy
 
Posts: 20
Joined: Fri Jun 11, 2004 1:48 pm

Postby dewey on Wed Jul 06, 2005 1:48 am

This may be because the strings are being store in a data segment, which is not compatible with native libraries.

Ensure that the PC-relative strings option is enabled in your project.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby izzy on Wed Jul 06, 2005 4:24 pm

It was enabled. Does the PC-relative Constant Data also need to be enabled? Anyway, I tried both ways and still got the same error.
izzy
 
Posts: 20
Joined: Fri Jun 11, 2004 1:48 pm

Postby dewey on Thu Jul 07, 2005 1:28 am

Try breaking down the initialization:
char* weekday[7];
weekday[0] = "Sunday";
...

This array is a local variable in a function, correct?
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron