Issue with C syntax
Ray0665
Posts: 231
Im getting a syntax warning I dont understand
can anyone help ?
I made the follow in declarations in C
#define stx 0x02
unsigned int GetByte() {int x; read (usbPort, &x, sizeof(x) ); return x; }
and I am getting the following warnings which I do not understand
warning: comparison between pointer and integer [enabled by default]
do while (GetByte != stx) {}
^
error: expected while before N
N = GetByte;
And later in the program I get this:
warning: assignment makes integer from pointer without a cast [enabled by default]
Ck2 = GetByte;
where Ck2 is declared as
unsigned short int N, Ck1, Ck2;
can anyone help ?
I made the follow in declarations in C
#define stx 0x02
unsigned int GetByte() {int x; read (usbPort, &x, sizeof(x) ); return x; }
and I am getting the following warnings which I do not understand
warning: comparison between pointer and integer [enabled by default]
do while (GetByte != stx) {}
^
error: expected while before N
N = GetByte;
And later in the program I get this:
warning: assignment makes integer from pointer without a cast [enabled by default]
Ck2 = GetByte;
where Ck2 is declared as
unsigned short int N, Ck1, Ck2;

Comments
while (GetByte() != stx) {}Also, your GetByte function is not going to do what you expect since you've declared x to be an int which is four bytes wide (32 bits) on the Propeller. You probably want to declare x to be of type char. The function, as you've written it, will try to read four bytes not one byte.You have cleared all the issues now I just have to remember it..