🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42423

Could someone help me with this assignment (casting) error?

#42423
From: Craig Shrimpton
Date: Fri, 08 Dec 1995 00:00
52 lines
2503 bytes
Greetings,

I've been trying to compile portmap_3 on my gcc-7.0, libc-5.0.9, 1.2.13 ELF 
Linux system.  I am having trouble with an error that I don't quite 
understand.  It looks as if the porgram should compile but it does not.  
What's real strange is that I did compile it once before without any trouble.  
As far as I know I didn't change anything (but I must have!).  Any help in 
understanding what's going on would be appreciated.

The error:

cc -DHOSTS_ACCESS -DCHECK_PORT  -DFACILITY=LOG_MAIL  -DIGNORE_SIGCHLD  
-D_USE_BS
D -D_USE_BSD_SIGNAL -O   -c pmap_check.c -o pmap_check.o
pmap_check.c: In function `logit':
pmap_check.c:236: warning: assignment makes pointer from integer without a 
cast
pmap_check.c:237: dereferencing pointer to incomplete type
make: *** [pmap_check.o] Error 1

The offending code:

      if (prognum == 0) {
            progname = "";
        } else if (rpc = getrpcbynumber((int) prognum)) {
            progname = rpc->r_name;
        } else {
            sprintf(progname = progbuf, "%lu", prognum);
        }

I don't understand why gcc complains about lack of casting since rpc is 
already defined as a pointer (struct rpcent *rpc).  I thought getrpcbynumber() 
returned a pointer to rpc but is it really returning an interger?  I guess I 
don't understand exactly what the error means because I can't figure out how 
to set the cast.  I thought what gcc wanted was ((struct rpcent *) rpc = 
....) but it complains about that.  I'm assuming that the second error means 
rpc is dereferenced because it is void.

This code is unmodified from the Slackware distrib. so it should compile.  
Anyone who knows the fix and could explain the nature of the error will be 
helping me greatly.

Thanks,

Craig


===================================================================
Shrimpton Consulting                         Orbit Systems
Craig Shrimpton                              Email:  craigs@os.com
17 Monroe Avenue                             Phone:  (508) 753-8776
Worcester, MA 01602                          http://www.os.com/
Technical Details
Message-ID: <4a9isc$sio@news.iii.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,cf1acb572b24d341,start
X-Google-Attributes: gid11318c,public
From: craigs@os.com (Craig Shrimpton)
Subject: Could someone help me with this assignment (casting) error?
Date: 1995/12/08
Message-ID: <4a9isc$sio@news.iii.net>
X-Deja-AN: 121283046
organization: Shrimpton Consulting
newsgroups: gnu.gcc.help