public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Lee Shallis <gb2985@gmail.com>
To: GCC Help <gcc-help@gcc.gnu.org>
Subject: Declaring a function to be of wprintf style
Date: Thu, 22 Sep 2022 17:24:32 +0100	[thread overview]
Message-ID: <CAOZ3c1r3tg5L9Xkvsjx9zWu3S+fgEZAKNfr6zKi9991Ae5rh9Q@mail.gmail.com> (raw)

I attempted this:

#ifdef __GNUC__
#define PAW__ATTR_PRINTF(ARGS_POS,VA_POS) \
    __attribute__((format (printf, ARGS_POS, VA_POS)))
#define PAW__ATTR_WPRINTF(ARGS_POS,VA_POS) \
    __attribute__((format (wprintf, ARGS_POS, VA_POS)))
#else
#define PAW__ATTR_PRINTF(ARGS_POS,VA_POS)
#define PAW__ATTR_WPRINTF(ARGS_POS,VA_POS)
#endif

#ifdef _DEBUG
#define PAW_ATTR_PRINTF(ARGS_POS,VA_POS) PAW__ATTR_PRINTF(ARGS_POS,VA_POS)
#define PAW_ATTR_WPRINTF(ARGS_POS,VA_POS) PAW__ATTR_WPRINTF(ARGS_POS,VA_POS)
#else
#define PAW_ATTR_PRINTF(ARGS_POS,VA_POS)
#define PAW_ATTR_WPRINTF(ARGS_POS,VA_POS)
#endif

But gcc gave this "error: ‘wprintf’ is an unrecognized format function
type", I also tried just printf but then it complained the args
parameter was not of char const *

Is there anyway to declare it to be of that style and if so is there a
way to extend what it checks for as I have some custom modifiers for
the string types & and some extra specifiers, 3 of which can change
what is expected to be found in the args, namely what options are
sought out, what modifiers are sought out and what specifiers are
sought out, I would greatly appreciate being able to get my arguments
checked for type mis-matches in the default scenarios during compile
time

                 reply	other threads:[~2022-09-22 16:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOZ3c1r3tg5L9Xkvsjx9zWu3S+fgEZAKNfr6zKi9991Ae5rh9Q@mail.gmail.com \
    --to=gb2985@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).