[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-ia64
Subject:    RE: Faulty ACPI debug code [was: Re: Booting a dual ...]
From:       John Baldwin <jhb () FreeBSD ! org>
Date:       2001-10-16 22:58:36
[Download RAW message or body]


On 16-Oct-01 Grover, Andrew wrote:
> Hi Peter,
> 
> Thanks for the problem reports. Our code can't use GCC extensions and
> maintain ANSI C conformance, but it sure looks like using them briefly and
> cleaning up the code would be a good thing to do...;-)

One thing you can do is use a macro similar to the way FreeBSD does:

/*
 * Compiler-dependent macros to declare that functions take printf-like
 * or scanf-like arguments.  They are null except for versions of gcc
 * that are known to support the features properly (old versions of gcc-2
 * didn't permit keeping the keywords out of the application namespace).
 */
#if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
#define __printflike(fmtarg, firstvararg)
#define __scanflike(fmtarg, firstvararg)
#else
#define __printflike(fmtarg, firstvararg) \
            __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#define __scanflike(fmtarg, firstvararg) \
            __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
#endif

You can then use '__printflike(4, 5)' instead of using __attribute__ directly.
This gives you all the warnings on newer versions of GCC while still allowing
the code to compile on other compilers without problems.

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ia64" in the body of the message


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic