What Am I Doing Wrong?

Discuss PocketC for Palm OS (including Desktop Edition)

Postby parker2r on Tue Mar 27, 2001 1:49 pm

Being new to the Ipaq and Pocket C Desktop and Device development, I thought I'd start of with something simple. When I downloaded the 'bit1' sample program to the Ipaq, it ran fine. However, when I tried to download the source file to the Ipaq to edit it, the device development editing package didn't want to know. Also, when I hand transcribed the 'bit1' program on the Ipaq, I got an 'expected token ,' error message when I copied, word for word, 'int num = 0;' What's going on?
after I substituted int num; num = 0;
I got past the error, but came to grief on 'bit_count'. Help!

int num = 0;
num = gets("Please enter a positive number: ");
alert("Number " + num + " has " + bit_count(num) + " bits");


bit_count(int x)
int n = 0;

if (x)
do {
} while ((x = x & (x-1)));

Posts: 3
Joined: Tue Mar 27, 2001 8:24 am
Location: United Kingdom

Postby Vilmos on Tue Mar 27, 2001 3:01 pm

I think the first problem is that you are trying to run PalmOS on the WinCE device. :)

I'm sure they will be more help in the WinCE forum, as the two versions of PocketC are not compatible.

Posts: 174
Joined: Tue Dec 05, 2000 6:13 pm
Location: Canada

Postby wolfgang on Tue Mar 27, 2001 3:30 pm


you must place the bit_count function BEFORE the code where you call it, i.e. before your "main" function. Then it will work.

Another possibility is to use a prototype, i.e. leave the bit_count function where it is, but add the following line BEFORE your "main" function:

bit_count(int x);

(do not forget the semicolon at the end of this line! It tells PocketC that this is only a prototype (defining the interface to the function) and not a full function definition.)

Composing music on the PocketPC! - http://www.pdamusician.com
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA

Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 3 guests