public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/32868]  New: Don't warn about redefinitions of __STDC_FORMAT_MACROS
@ 2007-07-23 17:28 ian at airs dot com
  2007-07-26 21:33 ` [Bug preprocessor/32868] " tromey at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ian at airs dot com @ 2007-07-23 17:28 UTC (permalink / raw)
  To: gcc-bugs

Compiling this C or C++ file:

#define __STDC_FORMAT_MACROS 1
#define __STDC_FORMAT_MACROS 1

produces these warnings:

foo.c:2:1: warning: "__STDC_FORMAT_MACROS" redefined
foo.c:1:1: warning: this is the location of the previous definition

This is because of these lines in libcpp/macro.c:

  if (! ustrncmp (NODE_NAME (node), DSC ("__STDC_")))
    node->flags |= NODE_WARN;

The idea behind these lines is sound: the compiler defines macros whose name
begins with "__STDC_".  The user should not redefine them.

However, __STDC_FORMAT_MACROS is an exception here.  This macro is not defined
by the compiler.  It is intended to be defined by the user when compiling a C++
file to direct the <stdint.h> header file to define macros PRId32 and friends. 
See footnote 182 in section 7.8.1 in C99.

If the user defines the macro in a .h file, as is permitted, then including
that some .h file twice, if it does not have an include guard, will give an
inappropriate warning.  In particular this can happen with an autoconf-style
config.h file, as autoconf does not generate include guards for such files.

I expect that the right fix is to specifically exclude __STDC_FORMAT_MACROS
from this warning.  Or perhaps another approach would be to specially mark the
macros defined in cpp_init_builtins.


-- 
           Summary: Don't warn about redefinitions of __STDC_FORMAT_MACROS
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32868


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

* [Bug preprocessor/32868] Don't warn about redefinitions of __STDC_FORMAT_MACROS
  2007-07-23 17:28 [Bug preprocessor/32868] New: Don't warn about redefinitions of __STDC_FORMAT_MACROS ian at airs dot com
@ 2007-07-26 21:33 ` tromey at gcc dot gnu dot org
  2007-11-27 20:53 ` tromey at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-07-26 21:33 UTC (permalink / raw)
  To: gcc-bugs



-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-07-26 21:33:20
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32868


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

* [Bug preprocessor/32868] Don't warn about redefinitions of __STDC_FORMAT_MACROS
  2007-07-23 17:28 [Bug preprocessor/32868] New: Don't warn about redefinitions of __STDC_FORMAT_MACROS ian at airs dot com
  2007-07-26 21:33 ` [Bug preprocessor/32868] " tromey at gcc dot gnu dot org
@ 2007-11-27 20:53 ` tromey at gcc dot gnu dot org
  2007-11-28 14:29 ` ian at airs dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-11-27 20:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tromey at gcc dot gnu dot org  2007-11-27 20:53 -------
I think your proposed fix sounds ok.

I don't have a copy of the C++ standard handy.
Does this bug apply to both C and C++, or only C?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32868


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

* [Bug preprocessor/32868] Don't warn about redefinitions of __STDC_FORMAT_MACROS
  2007-07-23 17:28 [Bug preprocessor/32868] New: Don't warn about redefinitions of __STDC_FORMAT_MACROS ian at airs dot com
  2007-07-26 21:33 ` [Bug preprocessor/32868] " tromey at gcc dot gnu dot org
  2007-11-27 20:53 ` tromey at gcc dot gnu dot org
@ 2007-11-28 14:29 ` ian at airs dot com
  2007-11-28 16:26 ` tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ian at airs dot com @ 2007-11-28 14:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ian at airs dot com  2007-11-28 14:29 -------
The C99 standard specifically calls out __STDC_FORMAT_MACROS as a macro which
may be defined before including <inttypes.h>.  Therefore, I believe that
warning about this definition is a bug for both C and C++.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32868


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

* [Bug preprocessor/32868] Don't warn about redefinitions of __STDC_FORMAT_MACROS
  2007-07-23 17:28 [Bug preprocessor/32868] New: Don't warn about redefinitions of __STDC_FORMAT_MACROS ian at airs dot com
                   ` (2 preceding siblings ...)
  2007-11-28 14:29 ` ian at airs dot com
@ 2007-11-28 16:26 ` tromey at gcc dot gnu dot org
  2007-11-30 18:24 ` tromey at gcc dot gnu dot org
  2007-11-30 18:25 ` tromey at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-11-28 16:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from tromey at gcc dot gnu dot org  2007-11-28 16:26 -------
Testing a patch.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tromey at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-07-26 21:33:20         |2007-11-28 16:26:34
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32868


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

* [Bug preprocessor/32868] Don't warn about redefinitions of __STDC_FORMAT_MACROS
  2007-07-23 17:28 [Bug preprocessor/32868] New: Don't warn about redefinitions of __STDC_FORMAT_MACROS ian at airs dot com
                   ` (3 preceding siblings ...)
  2007-11-28 16:26 ` tromey at gcc dot gnu dot org
@ 2007-11-30 18:24 ` tromey at gcc dot gnu dot org
  2007-11-30 18:25 ` tromey at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-11-30 18:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tromey at gcc dot gnu dot org  2007-11-30 18:24 -------
Subject: Bug 32868

Author: tromey
Date: Fri Nov 30 18:24:01 2007
New Revision: 130544

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130544
Log:
libcpp
        PR preprocessor/32868:
        * macro.c (_cpp_create_definition): Special case
        __STDC_FORMAT_MACROS.
gcc/testsuite
        PR preprocessor/32868:
        * gcc.dg/cpp/pr32868.c: New file.

Added:
    trunk/gcc/testsuite/gcc.dg/cpp/pr32868.c
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libcpp/ChangeLog
    trunk/libcpp/macro.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32868


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

* [Bug preprocessor/32868] Don't warn about redefinitions of __STDC_FORMAT_MACROS
  2007-07-23 17:28 [Bug preprocessor/32868] New: Don't warn about redefinitions of __STDC_FORMAT_MACROS ian at airs dot com
                   ` (4 preceding siblings ...)
  2007-11-30 18:24 ` tromey at gcc dot gnu dot org
@ 2007-11-30 18:25 ` tromey at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2007-11-30 18:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from tromey at gcc dot gnu dot org  2007-11-30 18:24 -------
Fix checked in.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32868


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

end of thread, other threads:[~2007-11-30 18:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-23 17:28 [Bug preprocessor/32868] New: Don't warn about redefinitions of __STDC_FORMAT_MACROS ian at airs dot com
2007-07-26 21:33 ` [Bug preprocessor/32868] " tromey at gcc dot gnu dot org
2007-11-27 20:53 ` tromey at gcc dot gnu dot org
2007-11-28 14:29 ` ian at airs dot com
2007-11-28 16:26 ` tromey at gcc dot gnu dot org
2007-11-30 18:24 ` tromey at gcc dot gnu dot org
2007-11-30 18:25 ` tromey at gcc dot gnu dot org

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).