delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/01/12:51:13

Date: Fri, 1 Sep 2000 12:41:27 +0200 (CEST)
Message-Id: <200009011041.MAA65728@login-2.eunet.no>
From: "Gisle Vanem" <gvanem AT eunet DOT no>
To: djgpp AT delorie DOT com
Cc: eliz AT is DOT elta DOT co DOT il
Subject: Re: __attribute__ for pointers
X-Mailer: Watt/POP
Reply-To: djgpp AT delorie DOT com

From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> said:

> > Date: Fri, 1 Sep 2000 08:00:44 +0200 (MET DST)
> > From: Gisle Vanem <giva AT bgnett DOT no>
> >
> > extern int (*__printf) (const char *fmt, ...)
> > #ifdef __GNUC__
> >   __attribute__((format(printf,1,2)))
> > #endif
> > ;
> >
> > Where '__printf' points to either a stdio or a conio-type function.
> >
> > But gcc 2.95.2 doesn't seem to allow such '__attribute__' for a pointer;
> >
> >  "argument format specified for non-function `__printf'"
>
> Did you try to put __attribute__ inside the parens in (*__printf)?

Tried it, but doesn't work;

  extern int (*__printf __attribute__((format(printf,1,2))))
              (const char *fmt, ...);
or
  extern int (*__printf) __attribute__((format(printf,1,2)))
              (const char *fmt, ...);


> If that doesn't help either, try using a typedef.

Did work either:

  typedef int (*PrintFunc) (const char *fmt, ...);

  extern PrintFunc __printf __attribute__((format(printf,1,2)));

or
  typedef int (*PrintFunc) (const char *fmt, ...)
    __attribute__((format(printf,1,2)));

  extern PrintFunc __printf;


Gisle V.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019