switch (expression)

Michael T Sullivan sullivan at vsi.UUCP
Thu Jul 14 01:03:03 AEST 1988


In article <1988Jul12.105547.13268 at light.uucp>, bvs at light.uucp (Bakul Shah) writes:
> dpANS says the expression in ``_s_w_i_t_c_h (expression)''
> must be an integer valued expression.  Any chance of
> getting this changed ``must be an integer or ptr valued
> expression''?  The current restriction forces one to use
> the messier and longer sequence of ``if..then..else if
> ...'' for pointers...
> 
> Note that the switch stmt can be used by casting the ptr
> to a long or an int, but I don't know if this is safe on
> all architectures -- (casts) should be avoided where
> possible.

I don't know about casting should be avoided.  I'm looking at shmop(2) manual
page for our 3B2 (shared memory operation) and it says:

	"Shmat {which is a char* function -mts} returns the data segment
	start address of the attached shared memory segment...

	Otherwise, a value of -1 is returned and errno is set to indicate
	the error."

Somebody at AT&T must think casting a pointer to an int (or a long) isn't
such a bad idea, unless I'm missing something (it has been known to happen).

-- 
Michael Sullivan			{uunet|attmail}!vsi!sullivan
V-Systems, Inc.  Santa Ana, CA		sullivan at vsi.com
ons, workstations, workstations, workstations, workstations, workstations, work



More information about the Comp.std.c mailing list