I checked "if( NBITS_PER_AUDIOSAMPLE==32 )" in the cvt32 before this changed and no, the compiler doesn't optimized it away.
Was NBITS_PER_AUDIOSAMPLE still a #define at this point?
It's not 'broken'. C/C++ never says how compiler should optimize or how much it should do. We can only second guess what a compiler will do. It's better to not rely on compiler optimization if we know better what we want.
const unsigned int NBITS_PER_AUDIOSAMPLE = sizeof(tAudioSample)<<3; changing the #define to a 'const int'(or even static) should not give the compiler a choice, it should evaluate the sizeof() and assign the result to NBITS_PER_AUDIOSAMPLE. That leaves us with: if( 16==16 ) Now, whether or not the compiler optimizes that out or not, as you say, is up to the compiler. But, is 'if(16==16)' comparison a big hit for you, assuming the compiler does not optimize it out? If so, then we really don't have much choice and I don't see a problem with the change. I still don't know if you are just trying to get the memcpy instead of the for-loop or you want to get rid of both the 'if' and the 'for-loop'. --greg. _______________________________________________ Audio-dev mailing list [email protected] http://lists.helixcommunity.org/mailman/listinfo/audio-dev
