From: "Josh Wilmes" <[EMAIL PROTECTED]>
>
> Good stuff! However, regarding the function pointer thing, i've got
compilers
> (tcc and lcc) which disagree with you.
>
> Using NULL where a function pointer is expected is considered an error by
> tcc, and a mandatory warning by lcc. It is my understanding that
conversion
> between data pointers and function pointers is forbidden under ANSI C89.
I've
> sent in several patches which jump through some fairly painful hoops
because of
> this. It seems rather necessary though, as we are committed to building
> as ANSIly as possible.
>
> Here are a page on the matter i found on google. I know i had some
> others, but I can't find them at the moment.
>
> http://www.devx.com/free/tips/tipview.asp?content_id=114
Interestingly enough that takes me to a page about VB and RDBMS. Guess they
moved it.
Given the age of these compilers, I'm sure they aim toward C90 conformance,
and the
only copy of a standard that I have is C99, but I managed to find this with
google:
http://groups.google.com/groups?selm=clcm-19971221-0004%40plethora.net&outpu
t=gplain
The relevant excerpt:
Using NULL in this way is perfectly conforming, as it is
expressly allowed by the standard in 6.2.2.3:
===================
An integral constant expression with the value 0, or such an
expression cast to type void *, is called a null pointer
constant. If a null pointer constant is assigned to or compared
for equality to a pointer, the constant is converted to a
pointer of that type. Such a pointer, called a null pointer, is
guaranteed to compare unequal to a pointer to any object or
function.
Two null pointers, converted through possibly different
sequences of casts to pointer types, shall compare equal.
====================
Still, if tcc won't take it, there's no sense in whining about it. This
should fix it:
###############################
diff -ur include/parrot/parrot.h include/myparrot/parrot.h
--- include/parrot/parrot.h Fri Feb 22 18:03:58 2002
+++ include/myparrot/parrot.h Sat Feb 23 03:03:50 2002
@@ -76,9 +76,11 @@
/* define some shortcuts for dealing with function pointers */
/* according to ANSI C, casting between function and non-function pointers
is
* no good, except in the special case of NULL. So we should use
"funcptr_t"
- * in place of void* when dealing with function pointers*/
+ * in place of void* when dealing with function pointers. Also, some
compilers
+ * do the wrong thing when assigning NULL to a function pointer, so we have
to
+ * use NULLfunc instead*/
typedef void (*funcptr_t)(void);
-#define NULLfunc NULL
+#define NULLfunc (funcptr_t)0
/* Provide support for inline keyword where available. Just make sure to
use
* "INLINE" instead and it will DTRT. */