Page 1 of 1

PostPosted: Tue Mar 27, 2001 1:49 pm
by parker2r
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)));


PostPosted: Tue Mar 27, 2001 3:01 pm
by Vilmos
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.


PostPosted: Tue Mar 27, 2001 3:30 pm
by wolfgang

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.)