For Programmers: Free Programming Magazines  


Home > Archive > VC Language > June 2005 > Why this error "error C2146: syntax error : missing ';' before identifier 'Lengt









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Why this error "error C2146: syntax error : missing ';' before identifier 'Lengt
iceColdFire

2005-06-03, 3:59 am

I have a VC++.net Win32 console application, however when I compile , I
get this error

error C2146: syntax error : missing ';' before identifier 'Length'

Explain...

Location pointed is

typedef struct _LIST
{
LPLINK Tail; //... List Tail pointer.
LPLINK Head; //... List Head pointer.
DWORD Length; //... List Length.
} LIST;

typedef LIST *LPLIST;
in List.h

Thanks,
a.a.cpp

adebaene@club-internet.fr

2005-06-03, 9:09 am



iceColdFire a =E9crit :
> I have a VC++.net Win32 console application, however when I compile , I
> get this error
>
> error C2146: syntax error : missing ';' before identifier 'Length'
>
> Explain...
>
> Location pointed is
>
> typedef struct _LIST
> {
> LPLINK Tail; //... List Tail pointer.
> LPLINK Head; //... List Head pointer.
> DWORD Length; //... List Length.
> } LIST;
>
> typedef LIST *LPLIST;
> in List.h


Is DWORD defined (that is, is Windows.h included?)

Arnaud
MVP - VC

Peter Koch Larsen

2005-06-03, 4:02 pm


"iceColdFire" <icoldfire@yahoo.com> skrev i en meddelelse
news:1117773337.562397.76440@g14g2000cwa.googlegroups.com...
>I have a VC++.net Win32 console application, however when I compile , I
> get this error
>
> error C2146: syntax error : missing ';' before identifier 'Length'
>
> Explain...
>
> Location pointed is
>
> typedef struct _LIST
> {
> LPLINK Tail; //... List Tail pointer.
> LPLINK Head; //... List Head pointer.
> DWORD Length; //... List Length.
> } LIST;
>
> typedef LIST *LPLIST;
> in List.h
>
> Thanks,
> a.a.cpp
>

Probably because DWORD is an unknown type.
By the way your code is dangerous and inherently nonportable. _LIST is a
reserved identifier (as are all identifiers with a leading underscore
followed by a capital letter). Upgrading your compiler might thus break this
code.
Using all CAPITAL_LETTERS for types is also a bad habit - standard
convention requires this to be reserved for macroes.
Finally, this is not C++ but C-style, but you probably know this already.

/Peter


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com