statements following strcpy cause parse error

Grant Gossett ggossett@symantec.com
Thu Feb 7 15:41:00 GMT 2002


Can anyone tell me if I am overlooking something here?


I have 2 programs here, one which compiles in gcc 2.96 and 3.03 and the
other which gives a parse error "before the last declaration of a char
array".

prog #1 which compiles fine:

#include <string.h>
int main()
{
     char filename[256];
     strcpy (filename, "/etc/bogus.conf\0");
     return 0;
}


prog # 2 which throws a parse error before 'char'  (meaning the strcpy
line??)

#include <string.h>
int main()
{
     char filename[256];
     strcpy (filename, "/etc/bogus.conf\0");
     char unused[256];
     return 0;
}

Am I missing something very obvious here? I've tried the above 2 programs
with 2 different distributiuons of linux (suse 7.2, redhat 7.2), 2
different versions of gcc (2.96 and 3.03) and the verision of glibc shipped
with RH 7.2 as well as the newest glibc available for download. I should
also mention I tried this with Visual C++ 6.0 and also the second wouldn't
compile but it gives a " missing ; before 'type' "error. This most likely
isn't just related to gcc, but I can't for the life of me figure out what
stupidity I am perpetrating here. I also should note that a declaration
such as "int bob = 0" instead of char unused also causes the same issue.

TIA
Grant




More information about the Gcc-help mailing list