|
Rockbox mail archiveSubject: Re: [ rockbox-Patches-699202 ] Custom Recording FilenamesRe: [ rockbox-Patches-699202 ] Custom Recording Filenames
From: Greg Haerr <greg_at_censoft.com>
Date: Sat, 8 Mar 2003 12:33:25 -0800 > You have a bit of code: *fmtPtr++ which perhaps should be *(fmtPtr++) as * > takes precedece over ++, which I think is probably not what you want! Actually, *fmtPtr++ and *(fmtPtr++) will always generate exactly the same code, since the pointer is post-incremented, and the original value used regardless of the parenthesis. If you want to increment first, then dereference, use *++fmtPtr. > You > want to increment the pointer, then dereference it, whereas the code is > trying to dereference then increment the contents! The real cause of the compiler warning in this case is that the order of evaluation of function arguments is not defined by the C standard: the following code snippet needs to be rewritten: snprintf(tmpBuf, sizeof(tmpBuf), "%%%c%c", *(fmtPtr-1), *fmtPtr++); This is because the value of fmtPtr is undefined for the first usage, since it may or may not have been autoincremented in the second use in the parameter list. Regards, Greg Received on 2003-03-08 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |