www.digitalmars.com         C & C++   DMDScript  

c++ - Typedefs

reply "John Lance" <JDLance prodigy.net> writes:
I am trying to do a typedef that I used to be able to do with another
compiler.

it is:

typedef char[80] char80;

with the result to create a type that causes the compiler to
create/reference an 80 character sized memory space of type char.

I think I may have the syntax wrong, but can the above be done with the
DigitalMars compiler?

I have done

typedef struct {
    char  item[80];
} char80;

but this is not so simple under some circumstances in accessing the data.
With byte alignment, the above struct works fine though with many functions
that use void * or with casting (ugh).

What say you folks to this and am I too far left or right of standards?
Jun 01 2002
parent Jan Knepper <jan smartsoft.cc> writes:
Try:

typedef char          char80 [ 80 ];

Jan



John Lance wrote:

 I am trying to do a typedef that I used to be able to do with another
 compiler.

 it is:

 typedef char[80] char80;

 with the result to create a type that causes the compiler to
 create/reference an 80 character sized memory space of type char.

 I think I may have the syntax wrong, but can the above be done with the
 DigitalMars compiler?

 I have done

 typedef struct {
     char  item[80];
 } char80;

 but this is not so simple under some circumstances in accessing the data.
 With byte alignment, the above struct works fine though with many functions
 that use void * or with casting (ugh).

 What say you folks to this and am I too far left or right of standards?

Jun 01 2002