&ff in some c source I found

Started by
4 comments, last by Th0ughtCr1me 13 years, 7 months ago
I want to try making a hooked music player function in SDL, but this question has nothing to do with SDL, and is rather a simple c question.

Specifically in the following source there is a "&ff" no quotes, is this c/c++ or a typo/html conversion error?


// make a music play function// it expects udata to be a pointer to an intvoid myMusicPlayer(void *udata, Uint8 *stream, int len){   int i, pos=*(int*)udata;   // fill buffer with...uh...music...   for(i=0; i<len; i++)      stream=(i+pos)&ff;   // set udata for next time   pos+=len;   *(int*)udata=pos;}...// use myMusicPlayer for playing...uh...musicint music_pos=0;Mix_HookMusic(myMusicPlayer, &music_pos);


Thanks, TC
_______________ Play my Game at neonswarm.com
Advertisement
It looks like a bitwise AND, though I would expect to see (i+pos)&0xff, unless that's somehow legal C to have a hexadecimal constant without 0x (or maybe its macro'd somewhere #define ff 0xff, I don't know).

Essentially it's truncating a 32 bit integer into an 8 bit integer by ANDing with 0x000000ff, as the value on the left side is an 8 bit integer.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Thanks very much for rapid reply, I'll try that :)
_______________ Play my Game at neonswarm.com
Silly question -- is there a variable declared elsewhere named "ff" that is accessible to this function?
Looks like a typo to me.
Not that I know of smr. Though &0xff now compiles, and thats better in a way, the function does not behave as expected, so thanks to everyone for help. I'll need separate research to further understand how the whole system functions :) TC
_______________ Play my Game at neonswarm.com

This topic is closed to new replies.

Advertisement