Is this a valid ANSI program?

David Tanguay datangua at watmath.waterloo.edu
Thu Jun 27 09:21:21 AEST 1991


In article <609 at mtndew.Tustin.CA.US> friedl at mtndew.Tustin.CA.US (Stephen J. Friedl) writes:
>	void foo(const char **xxx)
>	{
>		/* nothing */
>	}
>
>	main()
>	{
>	char	**p = 0;
>
>		foo(p);
>	}
>
>The compiler claims that the argument /p/ to the function foo()
>is incompatible with the prototype, and I just don't believe it.

I don't believe it, either. In 3.3.16.1, Simple Assignment, Constraints:
	both operands are pointers to qualified of unqualified versions
	of compatible types, and the type pointed to by the left has all
	the qualifications of the type pointed to by the right

Your code satisfies this constraint (the others don't pertain to the example).
If you remove one level of indirection, you have a very common situation,
with the way the library routines are declared.
E.g., int printf( const char *, ... )
-- 
David Tanguay                  datanguay at watmath.waterloo.edu
Thinkage, Ltd.                 dat at Thinkage.On.CA



More information about the Comp.lang.c mailing list