Article View: gnu.gcc.help
Article #41875GCC 2.6.3, srand(), and parse errors...
From: Robert Woodcock
Date: Fri, 09 Feb 1996 00:00
Date: Fri, 09 Feb 1996 00:00
52 lines
1615 bytes
1615 bytes
Can anyone tell me why this code works:
#include "stdio.h"
#include "sys/times.h"
void main2 (void);
main() {
/* initialize random number generator based on time */
struct tms *Times;
srand(times(Times));
main2();
}
void main2 (void) {
int c;
for (c = 1; c <= 10; c++) {
printf("%d\n",rand());
}
}
And this code doesn't compile?
#include "stdio.h"
#include "sys/times.h"
main() {
/* initialize random number generator based on time */
struct tms *Times;
srand(times(Times));
int c;
for (c = 1; c <= 10; c++) {
printf("%d\n",rand());
}
}
Gcc gives me these errors:
broken.rand2.c: In function `main':
broken.rand2.c:8: parse error before `int'
broken.rand2.c:9: `c' undeclared (first use this function)
broken.rand2.c:9: (Each undeclared identifier is reported only once
broken.rand2.c:9: for each function it appears in.)
It seems to do that for everything I put after that srand() call,
with the exception of calling functions without parameters.
Any ideas? Having a bunch of mainX()'s in my program isn't very
desirable... :(
--
Robert Woodcock - rcw@netcom.com
Entropy isn't what it used to be.
Technical Details
Message-ID:
<rcwDMIMDB.CuJ@netcom.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,347e6156d8698727,start X-Google-Attributes: gid11318c,public From: rcw@netcom.com (Robert Woodcock) Subject: GCC 2.6.3, srand(), and parse errors... Date: 1996/02/09 Message-ID: <rcwDMIMDB.CuJ@netcom.com> X-Deja-AN: 138581658 sender: rcw@netcom16.netcom.com organization: my computer newsgroups: gnu.gcc.help