Subject: Unable to C-compile simple program
To: NetBSD/arm32 mailing list <port-arm32@NetBSD.ORG>
From: Ib-Michael Martinsen <imm@nethotel.dk>
List: port-arm32
Date: 08/01/1998 21:10:31
Hi there,
Can anybody explain this oddity?
When I try to compile the following program:
#include <stdio.h>
#include <dirent.h>
void syntax(char *program) {
fprintf(stderr, "Syntax: %s [<directory>]\n", program);
}
int main(int argc, char *argv[]) {
DIR *dp;
dirent *de;
if (argc > 2) {
syntax(argv[0]);
exit(0);
}
if (argc == 1)
dp = opendir(".");
else
dp = opendir(argv[1]);
while ((de = readdir(dp)) != NULL) {
printf("%s\n", de->d_name);
}
closedir(dp);
return 0;
}
with the following command, I get the errors:
imm@nethotel:/home/imm/c => cc -o newexpire newexpire.c
newexpire.c: In function `main':
newexpire.c:14: `dirent' undeclared (first use this function)
newexpire.c:14: (Each undeclared identifier is reported only once
newexpire.c:14: for each function it appears in.)
newexpire.c:14: `de' undeclared (first use this function)
imm@nethotel:/home/imm/c =>
However, if I use g++ instead of cc, it compiles and executes
without any errors.
If it matters, I have made a symbolic link /usr/include to
point to /usr/include.UVM which contains the header-files.
But even when I remove the symbolic link and rename
/usr/include.UVM to /usr/include, the behavior of the
two compilers is the same.
Any explanation will be deeply appreciated!
Best regards
Ib-Michael
--
Ib-Michael Martinsen Email at work: dtpimm@dsg.dk
Fidomail: 2:234/181.9 Email at home: imm@nethotel.dk
Running RiscBSD v1.3a on an Acorn RiscPC with a 202.4 MHz StrongArm processor.