* #define vfprintf
@ 1998-04-08 15:08 Jeffrey A Law
0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey A Law @ 1998-04-08 15:08 UTC (permalink / raw)
To: ghazi; +Cc: egcs
Unfortunately it is not safe to #define vfprintf with arguments.
Consider what happens if a header file in /usr/include looks like
this:
extern vfprintf ();
Some compilers (notably HPs) will give an error because you don't
pass enough arguments to the "macro":
cpp: "stdio.h", line 216: warning 2005: vfprintf: Too few parameters (1) to macr
Jeff Law (law@cygnus.com)
Cygnus Solutions EGCS GNU Compiler System
http://www.cygnus.com http://www.cygnus.com/egcs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: #define vfprintf
1998-04-13 7:34 Kaveh R. Ghazi
@ 1998-04-15 2:29 ` Jeffrey A Law
0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey A Law @ 1998-04-15 2:29 UTC (permalink / raw)
To: Kaveh R. Ghazi; +Cc: egcs, wilson
In message < 199804131434.KAA04083@caip.rutgers.edu >you write:
> Sorry I didn't get back to you sooner, I was unavailable last
> week.
It's OK, I probably couldn't have reviewed it then anyway..
> Since I hadn't introduced any new vfprintf code yet, I wasn't
> sure what you meant until I bootstrapped the latest snapshot on hpux.
> But now I see what you mean. The hpux compiler chokes on my recent
> patch to cccp.c and cexp.y in which I moved the following existing code
> higher up in those files:
Ah, I should have tried to be clearer about how we got into this
situation. I just assumed that when I mentioned it you'd go "oh,
yea, silly mistake..."
[ ... ]
> None of the above code is new, just its position in the file
> changed. The reason I did this is because certain other cc's have the
> restriction that stdarg.h/varargs.h must appear before stdio.h.
> However, this causes the conflict on hpux (probably any KNR stage1 cc)
> between the macro and the prototype.
Right.
> This problem will go away when I submit patches to integrate
> vfprintf.c, because the vfprintf() macro in the above code won't be
> needed then. But I won't be done with that very soon, due to my own
> time constraints.
Any rough estimate? Weeks? months?
> If we need a stopgap measure, the following patch will do the
> trick. Let me know if you want me to install it or wait until
> vfprintf.c and the associated autoconf hackery is ready.
Unless the time frame for vfprintf is pretty small (week or so)
then I think we ought to go ahead and put the stopgap in.
jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: #define vfprintf
@ 1998-04-13 7:34 Kaveh R. Ghazi
1998-04-15 2:29 ` Jeffrey A Law
0 siblings, 1 reply; 5+ messages in thread
From: Kaveh R. Ghazi @ 1998-04-13 7:34 UTC (permalink / raw)
To: law; +Cc: egcs
> From: Jeffrey A Law <law@hurl.cygnus.com>
>
> Unfortunately it is not safe to #define vfprintf with arguments.
>
> Consider what happens if a header file in /usr/include looks like
> this:
>
> extern vfprintf ();
>
> Some compilers (notably HPs) will give an error because you don't
> pass enough arguments to the "macro":
>
> cpp: "stdio.h", line 216: warning 2005: vfprintf: Too few
> parameters (1) to macr
>
> Jeff Law (law@cygnus.com)
Sorry I didn't get back to you sooner, I was unavailable last
week.
Since I hadn't introduced any new vfprintf code yet, I wasn't
sure what you meant until I bootstrapped the latest snapshot on hpux.
But now I see what you mean. The hpux compiler chokes on my recent
patch to cccp.c and cexp.y in which I moved the following existing code
higher up in those files:
> #if defined (__STDC__) && defined (HAVE_VPRINTF)
> # include <stdarg.h>
> # define PRINTF_ALIST(msg) char *msg, ...
> # define PRINTF_DCL(msg)
> # define PRINTF_PROTO(ARGS, m, n) PROTO (ARGS) __attribute__ ((format (__printf__, m, n)))
> #else
> # include <varargs.h>
> # define PRINTF_ALIST(msg) msg, va_alist
> # define PRINTF_DCL(msg) char *msg; va_dcl
> # define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))
> # define vfprintf(file, msg, args) \
> { \
> char *a0 = va_arg(args, char *); \
> char *a1 = va_arg(args, char *); \
> char *a2 = va_arg(args, char *); \
> char *a3 = va_arg(args, char *); \
> fprintf (file, msg, a0, a1, a2, a3); \
> }
> #endif
None of the above code is new, just its position in the file
changed. The reason I did this is because certain other cc's have the
restriction that stdarg.h/varargs.h must appear before stdio.h.
However, this causes the conflict on hpux (probably any KNR stage1 cc)
between the macro and the prototype.
This problem will go away when I submit patches to integrate
vfprintf.c, because the vfprintf() macro in the above code won't be
needed then. But I won't be done with that very soon, due to my own
time constraints.
If we need a stopgap measure, the following patch will do the
trick. Let me know if you want me to install it or wait until
vfprintf.c and the associated autoconf hackery is ready.
--Kaveh
Mon Apr 13 10:35:19 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* cccp.c: Define macro VFPRINTF() instead of vfprintf(). If
VFPRINTF() is defined, define vfprintf to VFPRINTF but only after
system headers are included.
* cexp.y: Likewise.
diff -rup orig/egcs-980406/gcc/cccp.c egcs-980406/gcc/cccp.c
--- orig/egcs-980406/gcc/cccp.c Mon Apr 6 10:01:23 1998
+++ egcs-980406/gcc/cccp.c Mon Apr 13 09:43:58 1998
@@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA. */
# define PRINTF_ALIST(msg) msg, va_alist
# define PRINTF_DCL(msg) char *msg; va_dcl
# define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))
-# define vfprintf(file, msg, args) \
+# define VFPRINTF(file, msg, args) \
{ \
char *a0 = va_arg(args, char *); \
char *a1 = va_arg(args, char *); \
@@ -56,6 +56,10 @@ typedef unsigned char U_CHAR;
#include "gansidecl.h"
#include "pcp.h"
+
+#ifdef VFPRINTF
+#define vfprintf VFPRINTF
+#endif
#ifndef GET_ENVIRONMENT
#define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ENV_VALUE = getenv (ENV_NAME)
diff -rup orig/egcs-980406/gcc/cexp.y egcs-980406/gcc/cexp.y
--- orig/egcs-980406/gcc/cexp.y Mon Apr 6 10:01:24 1998
+++ egcs-980406/gcc/cexp.y Mon Apr 13 09:44:52 1998
@@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA.
# define PRINTF_ALIST(msg) msg, va_alist
# define PRINTF_DCL(msg) char *msg; va_dcl
# define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))
-# define vfprintf(file, msg, args) \
+# define VFPRINTF(file, msg, args) \
{ \
char *a0 = va_arg(args, char *); \
char *a1 = va_arg(args, char *); \
@@ -56,6 +56,10 @@ Boston, MA 02111-1307, USA.
#ifdef MULTIBYTE_CHARS
#include <locale.h>
+#endif
+
+#ifdef VFPRINTF
+#define vfprintf VFPRINTF
#endif
typedef unsigned char U_CHAR;
--
Kaveh R. Ghazi Project Manager / Custom Development
ghazi@caip.rutgers.edu Icon CMT Corp.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: #define vfprintf
1998-04-09 14:17 ` Ulrich Drepper
@ 1998-04-09 17:44 ` Jeffrey A Law
0 siblings, 0 replies; 5+ messages in thread
From: Jeffrey A Law @ 1998-04-09 17:44 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: egcs
In message < r2iuojeyg0.fsf@happy.cygnus.com >you write:
> law@cygnus.com (Jeffrey A Law) writes:
>
> > extern vfprintf ();
> >
> > Some compilers (notably HPs) will give an error because you don't
> > pass enough arguments to the "macro":
>
> This code is bogus. The source must be
>
> #ifndef vfprintf
> extern vfprintf ();
> #endif
>
>
> The C standard explicitly says that each function can be defined as a
> macro (in addition to a function definition).
Bogus or not, that's what appears in the hp include files and we
must be able to compile it with the HP bundled compiler, which is
not ANSI complaint.
jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: #define vfprintf
[not found] <25235.892064821.cygnus.egcs@hurl.cygnus.com>
@ 1998-04-09 14:17 ` Ulrich Drepper
1998-04-09 17:44 ` Jeffrey A Law
0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Drepper @ 1998-04-09 14:17 UTC (permalink / raw)
To: egcs
law@cygnus.com (Jeffrey A Law) writes:
> extern vfprintf ();
>
> Some compilers (notably HPs) will give an error because you don't
> pass enough arguments to the "macro":
This code is bogus. The source must be
#ifndef vfprintf
extern vfprintf ();
#endif
The C standard explicitly says that each function can be defined as a
macro (in addition to a function definition).
-- Uli
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1998-04-15 2:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-08 15:08 #define vfprintf Jeffrey A Law
[not found] <25235.892064821.cygnus.egcs@hurl.cygnus.com>
1998-04-09 14:17 ` Ulrich Drepper
1998-04-09 17:44 ` Jeffrey A Law
1998-04-13 7:34 Kaveh R. Ghazi
1998-04-15 2:29 ` Jeffrey A Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).