Re: How to understand this

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ulrich Eckhardt (doomster_at_knuut.de)
Date: 12/15/04


Date: Wed, 15 Dec 2004 09:57:24 +0100

Rui Tang wrote:
> typedef MEMBLOCK *SECTION[BLOCK_MASK+1];
>
> A little bit confused with the usage of the last typedef. If a variable
> is then declared as SECTION, like the following statement:
>
> SECTION NKSection;
>
> how will NKSection look like in memory?
>
> Can anyone help to translate this in a more understandable way? Thanks
> in advance.

You have to read typedefs from the inside out (reading from left to right
only applies when typedefing objecttypes, not for functions or arrays),
starting at the newly introduced name. In this case, SECTION is an array of
(BLOCK_MASK+1) pointers to MEMBLOCK.

Uli



Relevant Pages

  • Re: How to understand this
    ... > Rui Tang wrote: ... >> A little bit confused with the usage of the last typedef. ... > only applies when typedefing objecttypes, not for functions or arrays), ...
    (microsoft.public.windowsce.platbuilder)
  • Re: [C] functions and 2D arrays?
    ... >>This works, and I like the idea of using typedef, but to solidify ... 'int ' for every instance of 'foo bar' in the code. ... to arrays of arrays of int, when you could be passing pointers ...
    (alt.comp.lang.learn.c-cpp)
  • Re: size of a typedef with arrays of unsigned char
    ... arrays of unsigned char, the sum of the size of the arrays? ... The reference to typedef is irrelevant. ... in a record consisting of arbitrary byte-sized chunks, ...
    (comp.lang.c)
  • Re: Returning structs containing arrays
    ... > of ints and an int. ... contains two pointers and an integer. ... arrays if you initialize them to point to allocated memory. ... The typedef "arrays" doesn't name a structure type; ...
    (comp.lang.c)
  • Re: Diffs between OpenBSD 3.9 gcc 3.3.5 <-> Linux 2.6 gcc 4.0 ?
    ... BobH, thanks for your advice but I regret to say that I've already ... typedef unsigned char UINT8; ... I have had mixed luck assuming that function calls passing arrays ...
    (comp.unix.bsd.openbsd.misc)