🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by Marc Goldberg Fri, 08 Mar 1996 15:08
help: gcc
#1
Author: Marc Goldberg
Date: Fri, 08 Mar 1996 15:08
45 lines
1420 bytes
Trying to compile a program on Solaris 2.5, I've removed all bugs (syntax 
errors, at least) but these.  Any help would be *greatly* appreciated.

Thanks,
--Marc

~~~~~
spiffy@felix:5: gcc 2FarmCheck.c 
2FarmCheck.c: In function `readHostFiles':
2FarmCheck.c:23: dereferencing pointer to incomplete type
2FarmCheck.c:25: dereferencing pointer to incomplete type
2FarmCheck.c:27: warning: passing arg 3 of `fgets' from incompatible 
		 pointer type
2FarmCheck.c: In function `main':
2FarmCheck.c:66: storage size of `PID' isn't known
~~~~~~

The lines referred to are:

char *readHostFiles(char *name)
      {
      int foo;
      struct FILE *fileDisc;

(23)  *fileDisc = fopen("/users/spiffy/urls.txt", O_RDONLY);

(25)  while (!feof(fileDisc))
        {
(27)      if ( fgets(name, HOSTNAMESIZE, fileDisc) != name)
          exit(12);
        }
      return name; 
      } 
|
|
|
int main(void)
      {
(66)  struct pid_t PID;
      char name[HOSTNAMESIZE];        /*Hostname of server to check on*/

      PID = getpid();
      ...other stuff...
      }
Re: help: gcc
#2
Author: Matthias Dittrich
Date: Mon, 11 Mar 1996 07:36
52 lines
1918 bytes
spiffy@seas.gwu.edu (Marc Goldberg) wrote:
>
>Trying to compile a program on Solaris 2.5, I've removed all bugs (syntax 
>errors, at least) but these.  Any help would be *greatly* appreciated.
>
>Thanks,
>--Marc
>
>~~~~~
>spiffy@felix:5: gcc 2FarmCheck.c 
>2FarmCheck.c: In function `readHostFiles':
>2FarmCheck.c:23: dereferencing pointer to incomplete type
>2FarmCheck.c:25: dereferencing pointer to incomplete type
>2FarmCheck.c:27: warning: passing arg 3 of `fgets' from incompatible 
>		 pointer type
>2FarmCheck.c: In function `main':
>2FarmCheck.c:66: storage size of `PID' isn't known
>~~~~~~
>
>The lines referred to are:
>
>char *readHostFiles(char *name)
>      {
>      int foo;
>      struct FILE *fileDisc;
>
>(23)  *fileDisc = fopen("/users/spiffy/urls.txt", O_RDONLY);
>
>(25)  while (!feof(fileDisc))
>        {
>(27)      if ( fgets(name, HOSTNAMESIZE, fileDisc) != name)
>          exit(12);
>        }
>      return name; 
>      } 
>|
>|
>|
>int main(void)
>      {
>(66)  struct pid_t PID;
>      char name[HOSTNAMESIZE];        /*Hostname of server to check on*/
>
>      PID = getpid();
>      ...other stuff...
>      }
You have to include the header files which are defining the missung types and
functions. These should be stdio.h for file handling and sys/unistd.h for
getpid() and pid_t.

Good luck,
Matthias
Re: help: gcc
#3
Author: Kurt Watzka
Date: Mon, 11 Mar 1996 16:07
94 lines
3461 bytes
Matthias Dittrich <matti> writes:

>spiffy@seas.gwu.edu (Marc Goldberg) wrote:
>>
>>Trying to compile a program on Solaris 2.5, I've removed all bugs (syntax 
>>errors, at least) but these.  Any help would be *greatly* appreciated.
>>
>>Thanks,
>>--Marc
>>
>>~~~~~
>>spiffy@felix:5: gcc 2FarmCheck.c 
>>2FarmCheck.c: In function `readHostFiles':
>>2FarmCheck.c:23: dereferencing pointer to incomplete type
>>2FarmCheck.c:25: dereferencing pointer to incomplete type
>>2FarmCheck.c:27: warning: passing arg 3 of `fgets' from incompatible 
>>		 pointer type
>>2FarmCheck.c: In function `main':
>>2FarmCheck.c:66: storage size of `PID' isn't known
>>~~~~~~
>>
>>The lines referred to are:
>>
>>char *readHostFiles(char *name)
>>      {
>>      int foo;
>>      struct FILE *fileDisc;

FILE _is_ a "struct _iobuf" or something similar in most implementations.
So, struct FILE is an incomplete type, and is _not_ related to FILE,
because struct "tags" and typedefed names live in different namespaces.

>>
>>(23)  *fileDisc = fopen("/users/spiffy/urls.txt", O_RDONLY);

The function fopen()  I know returns a "FILE *". So, if fileDisc would
be defined as "FILE *fileDisc", no dereferencing would be needed.OTOH,
the function I know takes a "const char *" as it's second argument,
so maybe we are talking about different functions.

>>
>>(25)  while (!feof(fileDisc))
>>        {
>>(27)      if ( fgets(name, HOSTNAMESIZE, fileDisc) != name)
>>          exit(12);
>>        }

In C, feof() is not endowed with clairvoyance, a simple fgets() would
do all you need to both read a line from the file and find out 
whether you have reached the end of that file.

>>      return name; 
>>      } 
>>|
>>|
>>|
>>int main(void)
>>      {
>>(66)  struct pid_t PID;

This is _very_ system specific, but if you are talking about a
system that is somehow similar to the system I am thinking about
(happens to be Solaris 2.4), a pid_t is certainly not a struct,
but it might have been introduced by something like 

   typedef long pid_t;

Again, "struct pid_t" is an incomplete type that is _not_ related
to the typedef name "pid_t".

>>      char name[HOSTNAMESIZE];        /*Hostname of server to check on*/
>>
>>      PID = getpid();
>>      ...other stuff...
>>      }

>You have to include the header files which are defining the missung types and
>functions. These should be stdio.h for file handling and sys/unistd.h for
>getpid() and pid_t.

I do _not_ agree with this analysis. Without a prototype for fgets()
in scope, the argument type mismatch for that function could not
have been detected.

The main source of the problem seems to be that struct "tags" and
typedefed names do not live in the same namespace, so the compiler
is not able do diagnose the kind of confusion that the original
poster suffers from.

Kurt
--
| Kurt Watzka                             Phone : +49-89-2180-6254
| watzka@stat.uni-muenchen.de
| ua302aa@sunmail.lrz-muenchen.de
Re: help: gcc
#4
Author: Marc Goldberg
Date: Mon, 11 Mar 1996 18:02
9 lines
645 bytes
	Thanks for all the reponses!  The upshot of what I received is:

1.  pid_t is a typedef, not a struct
2.  and line 23 -- syntax error with my pointer assignment.

	Everything else was fixed with these two corrections.

Thx,
Marc
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads