Commit 46b6bb95 by Neil Booth Committed by Neil Booth

README.Portability: Correct example about calling a function through a pointer to function.

	* README.Portability: Correct example about calling a function
	through a pointer to function.  Format wide paragraphs.

From-SVN: r35043
parent 1b0bd03b
2000-07-15 Neil Booth <NeilB@earthling.net>
* README.Portability: Correct example about calling a function
through a pointer to function. Format wide paragraphs.
2000-07-15 Michael Meissner <meissner@redhat.com> 2000-07-15 Michael Meissner <meissner@redhat.com>
* README.Portability: Update integer suffixes and function * README.Portability: Update integer suffixes and function
......
...@@ -155,22 +155,23 @@ ansidecl.h for the definitions of the above macros and more. ...@@ -155,22 +155,23 @@ ansidecl.h for the definitions of the above macros and more.
#define PARAMS(paramlist) () /* K+R C. */ #define PARAMS(paramlist) () /* K+R C. */
#define VPARAMS(args) (va_alist) va_dcl #define VPARAMS(args) (va_alist) va_dcl
One aspect of using K+R style function declarations, is you cannot have One aspect of using K+R style function declarations, is you cannot
arguments whose types are char, short, or float, since without prototypes (ie, have arguments whose types are char, short, or float, since without
K+R rules), these types are promoted to int, int, and double respectively. prototypes (ie, K+R rules), these types are promoted to int, int, and
double respectively.
Calling functions through pointers to functions Calling functions through pointers to functions
----------------------------------------------- -----------------------------------------------
K+R C compilers require brackets around the dereferenced pointer 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 *)); typedef void (* cl_directive_handler) PARAMS ((cpp_reader *, const char *));
p->handler (pfile, p->arg); *p->handler (pfile, p->arg);
needs to become needs to become
(p->handler) (pfile, p->arg); (*p->handler) (pfile, p->arg);
Macros Macros
...@@ -244,11 +245,12 @@ them. ...@@ -244,11 +245,12 @@ them.
Suffixes on Integer Constants Suffixes on Integer Constants
----------------------------- -----------------------------
K+R C did not accept a 'u' suffix on integer constants. If you want to declare K+R C did not accept a 'u' suffix on integer constants. If you want
a constant to be be unsigned, you must use an explicit cast. 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 You should never use a 'l' suffix on integer constants ('L' is fine),
can easily be confused with the number '1'. since it can easily be confused with the number '1'.
Common Coding Pitfalls Common Coding Pitfalls
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment