This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch -Wtraditional, warn about `U' integer constant suffix


On Mon, Aug 07, 2000 at 01:58:58PM -0400, Kaveh R. Ghazi wrote:
> Hmm, I've come across a problem in practice with this.  I'd like to
> solicit opinions on how to proceed.
> 
> Suppose you have the following code:
> 
>  > #include <limits.h>
>  > unsigned int i = UINT_MAX;
> 
> and suppose that your system is a modern one supporting U so limits.h
> defines UINT_MAX to 4294967295U.  Now you are hosed, there is no way
> to silence the warning.  Even though UINT_MAX is defined in a system
> header, the use of it occurs in user code so the warning will appear.
> Ditto for uses in cpp #if conditionals.
> 
> Any suggestions on how to avoid this problem?

__extension__ isn't appropriate and would require modifying the system
headers.

In theory, you could preserve information about where each macro
definition came from.  For all macros defined in system headers,
toggle system-header-ness on and off when you step in and out of the
expansion.  This may be possible right now for warnings generated by
the preprocessor.  The compiler doesn't have access to that level of
detail - the integrated preprocessor mode *could* do it, but you'd
have to augment the interface.  All in all, more work than I have time
for right now.

zw

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]