diff options
author | kan <kan@FreeBSD.org> | 2003-07-11 03:40:53 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2003-07-11 03:40:53 +0000 |
commit | b2a8872fbe1ec1c49094559ac7b78e6ea4ab7180 (patch) | |
tree | f6b0610f4a17fd26aa234354f050080f789861a4 /contrib/gcc/README.Portability | |
parent | 52e69d78eee5612ac195e0701a5cebe40d1ab0e1 (diff) | |
download | FreeBSD-src-b2a8872fbe1ec1c49094559ac7b78e6ea4ab7180.zip FreeBSD-src-b2a8872fbe1ec1c49094559ac7b78e6ea4ab7180.tar.gz |
Gcc 3.3.1-pre as of 2003-07-11.
Diffstat (limited to 'contrib/gcc/README.Portability')
-rw-r--r-- | contrib/gcc/README.Portability | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/contrib/gcc/README.Portability b/contrib/gcc/README.Portability index d69c386..04638b2 100644 --- a/contrib/gcc/README.Portability +++ b/contrib/gcc/README.Portability @@ -123,8 +123,19 @@ int myfunc PARAMS ((double, int *)); int myfunc (var1, var2) - double var1; - int *var2; + double var1; + int *var2; +{ + ... +} + +This implies that if the function takes no arguments, it should be +declared and defined as follows: + +int myfunc PARAMS ((void)); + +int +myfunc () { ... } @@ -139,32 +150,16 @@ void cpp_ice PARAMS ((cpp_reader *, const char *msgid, ...)); void cpp_ice VPARAMS ((cpp_reader *pfile, const char *msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - cpp_reader *pfile; - const char *msgid; -#endif - va_list ap; - - VA_START (ap, msgid); - -#ifndef ANSI_PROTOTYPES - pfile = va_arg (ap, cpp_reader *); - msgid = va_arg (ap, const char *); -#endif +{ + VA_OPEN (ap, msgid); + VA_FIXEDARG (ap, cpp_reader *, pfile); + VA_FIXEDARG (ap, const char *, msgid); ... - va_end (ap); + VA_CLOSE (ap); } -For the curious, here are the definitions of the above macros. See -ansidecl.h for the definitions of the above macros and more. - -#define PARAMS(paramlist) paramlist /* ISO C. */ -#define VPARAMS(args) args - -#define PARAMS(paramlist) () /* K+R C. */ -#define VPARAMS(args) (va_alist) va_dcl +See ansidecl.h for the definitions of the above macros and more. One aspect of using K+R style function declarations, is you cannot have arguments whose types are char, short, or float, since without @@ -305,8 +300,8 @@ long and int are not the same size. Second, if you write a function definition with no return type at all: - operate(a, b) - int a, b; + operate (a, b) + int a, b; { ... } @@ -319,8 +314,8 @@ Implicit function declarations always have return type int. So if you correct the above definition to void - operate(a, b) - int a, b; + operate (a, b) + int a, b; ... but operate() is called above its definition, you will get an error |