This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: README.Portability


John Marshall wrote:-

> This should be
>       (*p->handler) (pfile, p->arg);
> 
> It's not the parentheses it needs so much as the dereference.  Then
> the parentheses are needed to get the precedence right, of course.
> If you think about it, the K&R syntax is pedantically right; the ISO C
> relaxation allows you to call a function pointer instead of requiring
> you to dereference the pointer into a function before calling it.

Thanks John, I've returned it to the original code with the diff
below.

Neil.


Index: README.Portability
===================================================================
RCS file: /cvs/gcc/egcs/gcc/README.Portability,v
retrieving revision 1.3
diff -u -p -r1.3 README.Portability
--- README.Portability	2000/07/15 04:18:47	1.3
+++ README.Portability	2000/07/15 04:54:00
@@ -155,22 +155,23 @@ ansidecl.h for the definitions of the ab
 #define PARAMS(paramlist)  ()         /* K+R C.  */
 #define VPARAMS(args)   (va_alist) va_dcl
 
-One aspect of using K+R style function declarations, is you cannot have
-arguments whose types are char, short, or float, since without prototypes (ie,
-K+R rules), these types are promoted to int, int, and double respectively.
+One aspect of using K+R style function declarations, is you cannot
+have arguments whose types are char, short, or float, since without
+prototypes (ie, K+R rules), these types are promoted to int, int, and
+double respectively.
 
 Calling functions through pointers to functions
 -----------------------------------------------
 
 K+R C compilers require brackets around the dereferenced pointer
-variable.  For example
+variable, whereas ISO C relaxes the syntax.  For example
 
 typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
-      p->handler (pfile, p->arg);
+      *p->handler (pfile, p->arg);
 
 needs to become
 
-      (p->handler) (pfile, p->arg);
+      (*p->handler) (pfile, p->arg);
 
 
 Macros
@@ -244,11 +245,12 @@ them.
 Suffixes on Integer Constants
 -----------------------------
 
-K+R C did not accept a 'u' suffix on integer constants.  If you want to declare
-a constant to be be unsigned, you must use an explicit cast.
+K+R C did not accept a 'u' suffix on integer constants.  If you want
+to declare a constant to be be unsigned, you must use an explicit
+cast.
 
-You should never use a 'l' suffix on integer constants ('L' is fine), since it
-can easily be confused with the number '1'.
+You should never use a 'l' suffix on integer constants ('L' is fine),
+since it can easily be confused with the number '1'.
 
 
 			Common Coding Pitfalls

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]