regcmp()

Chris Torek chris at trantor.umd.edu
Fri Feb 19 19:07:00 AEST 1988


>>>The problem is with what you are passing.  You are passing (char *)0
>>>instead of (char *)NULL.

[(char *)0 and (char *)NULL are required to be the same!]

>>Not if you cast it to "char *", it isn't!  Passing "(char *)0" is quite
>>sufficient, unless the compiler is horribly broken.  [Guy Harris]

In article <15100006 at bucc2> brian at bucc2.UUCP writes:
>  Tsk, tsk, tsk. This statment is true if sizeof(int) == sizeof(pointer).
>Not a good assumption to make, eh? I do a great deal of programming using
>Microsoft C 5.0 on IBM PEE CEE's. In large model, pointers are four bytes
>long. However, constant integer expessions are ints, and an int is only two
>bytes long.

NO!  NO NO NO NO NO   *grumble*

Constant integer expressions are indeed ints.  (char *)0 is not
a constant integer expression, it is a constant expression of type
`pointer to char'.

Incidentally, Microsoft's definition of NULL as 0L is technically
legal, but is a bad idea.  It covers up code bugs in large model,
but they still show in mixed model code.

Once again:

	(char *)0
	(char *)0L
	(char *)NULL

are all identical in both value and type.  `0' is a proper nil
pointer of any type as long as it is in a context that coerces it
to a pointer.  Assignment, comparison, and casts provide context;
function calls do not[*].  It is that simple.

-----
[*] except when a prototype is in scope
-- 
In-Real-Life: Chris Torek, Univ of MD Computer Science, +1 301 454 7163
(hiding out on trantor.umd.edu until mimsy is reassembled in its new home)
Domain: chris at mimsy.umd.edu		Path: not easily reachable



More information about the Comp.unix.questions mailing list