linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using both wchar_t and GCC __attribute__((format(...)))
@ 2007-07-02 19:52 Pedro de Medeiros
  2007-07-03  4:03 ` cyon.john
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro de Medeiros @ 2007-07-02 19:52 UTC (permalink / raw)
  To: linux-c-programming

Hello,

I am trying to convert some functions in my library from (char *) to
(wchar_t *), and it has been a bit of a nightmare. I want to use GCC error
detection for printf-style functions, but that doesn't seem to work when
functions use wchar_t *. For instance:

void trace(conn_t *, wchar_t *, ...)
        __attribute__ ((format(printf, 2, 3)));

And GCC aborts with:

"error: format string argument not a string type"

Then I tried something like:

void trace(conn_t *, wchar_t *, ...)
        __attribute__ ((format(wprintf, 2, 3)));

But GCC tells me that:

"warning: 'wprintf' is an unrecognized format function type"

Which I assume will disable GCC printf-style error checking.

How do I solve this other than disabling this feature completely?
Any help would be greatly appreciated.

Cheers,
Pedro.

-- 
Pedro de Medeiros - Ciência da Computação - Universidade de Brasília
Home Page: http://www.nonseq.net - Linux User No.: 234250
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Using both wchar_t and GCC __attribute__((format(...)))
  2007-07-02 19:52 Using both wchar_t and GCC __attribute__((format(...))) Pedro de Medeiros
@ 2007-07-03  4:03 ` cyon.john
  0 siblings, 0 replies; 2+ messages in thread
From: cyon.john @ 2007-07-03  4:03 UTC (permalink / raw)
  To: pedrovmm+lists, linux-c-programming

Hi, 

I haven't used this attribute before, but the following is what I feel
after giving it a try now...

> void trace(conn_t *, wchar_t *, ...)
>         __attribute__ ((format(printf, 2, 3)));
> 
> And GCC aborts with:
> 
> "error: format string argument not a string type"

Here, the error is due to the fact that gcc expects the 'string-index'
parameter of format attribute to point to 'const char *' type.

> void trace(conn_t *, wchar_t *, ...)
>         __attribute__ ((format(wprintf, 2, 3)));
> 
> But GCC tells me that:
> 
> "warning: 'wprintf' is an unrecognized format function type"

This error is because, according to gcc-4.2.0 manual it only supports
the following - printf, scanf, strftime or strfmon - for the 'archetype'
parameter offormat attribute.

So I feel we are out of luck unless gcc adds support for 'wprintf' as
archetype for format attribute.

I found a mail loop at gcc-patches mailing list where a patch is
submitted to add this support and its discussion. I am not sure if has
got approved, but you may take a look at it.

Here is the link -
http://gcc.gnu.org/ml/gcc-patches/2001-12/msg01579.html

Hope that will help you.

Regards,
Cyon


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-03  4:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-02 19:52 Using both wchar_t and GCC __attribute__((format(...))) Pedro de Medeiros
2007-07-03  4:03 ` cyon.john

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 NNTP newsgroup(s).