[Flac-dev] const issue in FLAC__lpc_compute_residual_from_qlp_coefficients (libFLAC/lpc.c:233)

Christian Hudon chrish at pianocktail.org
Wed Jan 14 08:28:05 PST 2004


>>>The compilers yells at me on line 233 of libFLAC/lpc.c
>>>
>>>*(residual++) = *(data++) - (sum >> lp_quantization);
>>>--> data is const and cannot be modified
>>>
>>>Funny thing is, if data is declared:
>>>   const FLAC__int32 *data
>>>instead of
>>>   const FLAC__int32 data[]
>>>
>>>everything is ok.
>>>
>>>Is this a bug in my compiler, or a personnal lack of understanding of
>>>the difference in C between *data and data[] ?
>>>      
>>>

I'm not a great language lawyer, but I don't think you can modify the 
pointer when something is declared int foo[]. You can modify the data 
pointed to, with foo[0] = 42, etc. but you can't do stuff like foo++ or 
foo = (int*)something. The same error would show up with FLAC__int32 * 
const data. If you want to change the pointer, you need to declare it as 
a pointer with int *foo (or const int *foo, which means you can modify 
the pointer, but not the data it points to).

My 2 cents. I'll go back to lurking now. :-)

  Christian





More information about the Flac-dev mailing list