Binary data in the code?

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sat Nov 4 09:34:57 PST 2006


Jarrett Billingsley wrote:
> "Bill Baxter" <wbaxter at gmail.com> wrote in message 
> news:eihhpl$1ish$1 at digitaldaemon.com...
> 
> 
>>Or live with a dynamic array:
>>  static const ubyte[] data = {99,12,2,21};
> 
> 
> Actually, if you then write
> 
> data.length = 6;
> 
> The compiler will complain.
> 
> However, getting data.sizeof does still return 8, which is the size of a 
> dynamic array reference.. so.. hmm, confusing. 
> 
> 

Of course one can get the "actual" size by doing 'data.length * (typeof(data[0]).sizeof)' 
but... ack, if you need to use this a lot (which I assume he will).  Might be another 
example of where an expression alias would be useful.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d-learn mailing list