If you're using VC, you should see for errors/warnings about this - like
C2229, C2123 - it should error if you're using the /Za switch I think?
The only time I've seen something like this before is, for example, here:
typedef struct _RECOGNIZEDATATABLE
{
WORD nRecognizeDatas; //... number of RECOGNIZEDATA
structures
RECOGNIZEDATA RecognizeData[0]; //... array of RECOGNIZEDATA
structures follows
} RECOGNIZEDATATABLE;
typedef struct _RECOGNIZEDATA
{
WORD ProtocolID; //... Protocol which was recognized
WORD nProtocolOffset; //... Offset from the start of the frame
of the start of this protocol.
LPVOID InstData; //... Opaque, for protocol only.
} RECOGNIZEDATA;
The use if fairly obvious I think?
Interested in comments about how to do this using -ansi though.
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:di**********@chessie.cirr.com...
Lokicer <lo*****@163.com> wrote:
typedef struct tag_NullMsg
{
int a[0];
} tNullMsg;
Attempting to use a zero-length array is a constraint violation
requiring a diagnostic. Everything after that is outside the scope of
the Standard (both C89 and C99, I believe).
//#pragma pack()
int main(int arg)
{
printf("size of tNullMsg is %d\n", sizeof(tNullMsg));
printf("size of tCharMsg is %d\n", sizeof(tCharMsg));
}
who can explain it ?
thanks very much!
People who understand the use of your implementation - seek another
newsgroup for that.
http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.