TIP: Click on subject to list as thread! ANSI
echo: cis.os9.68000.osk
to: all
from: Bob van der Poel 76510,2203
date: 1992-07-27 23:45:38
subject: #C strangeness

#: 16052 S12/OS9/68000 (OSK)
    27-Jul-92  23:45:38
Sb: #C strangeness
Fm: Bob van der Poel 76510,2203
To: all

I'm writing a bit of C code using data modules and have found an interesting
situation. Most of the module functions are declared as returning a pointer to
a structure of type mod_exec. Further, if these functions fail, they return a
-1.

Now things get interesting. The compiler correctly flags statements like:

  if((foo=modlink(woof,type))==-1)...

as an illegal pointer/integer combination. This makes sense since pointers are
by their nature unsigned. So, what casts can one use to satisfy the compiler
and ensure that the proper type conversions are being done?

There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.