Hi, Alois! Good to hear from you - I hope all is going well.
ANYWAY:
1. I think the text you cut/pasted was garbled: it is not legal C (or C++) as-is.
2. Here are the errors I got when I tried to compile:
Quote:
gcc -Wall -pedantic -g -o xx xx.c
xx.c: In function `main':
xx.c:8: warning: ISO C forbids nested functions
xx.c:8: error: syntax error before "l"
xx.c:9: error: `count' undeclared (first use in this function)
xx.c:9: error: (Each undeclared identifier is reported only once
xx.c:9: error: for each function it appears in.)
xx.c:11: error: parse error before '}' token
|
3. I modified it with (guesses) as to what it might have meant, along with explanatory comments:
Code:
#include <stdio.h>
typedef unsigned short uint16;
int
main ()
{
#if TOTALLY_BOGUS_SPACING
uint16 t l e d s = count e r >> 4 ;
count e r = (message|>s t r eng th + 60) & 0 x f f ;
#else
/* Define variables, "counter", "strength" and "message" */
uint16 counter = 100, strength = 10, message = 0x100;
/* Variable "tled" takes the left (12?) bits of "counter"
(and gets rid of the rightmost, least significant 4 bits) */
uint16 tleds = counter >> 4;
/* I'd parenthesize more ... but this code snippet:
a) adds strength + 60 (here, strength = 70)
b) OR's the sum against message: 70 | 100 == 102
... and ...
c) AND's the result against 0x100 (102 & 256 == 0) */
counter = (message | strength + 60) & 0xff;
#endif
return 0;
}
'Hope that helps .. PSM