[cfe-commits] r68169 - /cfe/trunk/lib/Headers/limits.h
Howard Hinnant
hhinnant at apple.com
Wed Apr 1 09:10:58 PDT 2009
On Mar 31, 2009, at 8:44 PM, Chris Lattner wrote:
> Author: lattner
> Date: Tue Mar 31 19:44:37 2009
> New Revision: 68169
>
> URL: http://llvm.org/viewvc/llvm-project?rev=68169&view=rev
> Log:
> add support for the LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX
> limits.h GNU extensions.
> rdar://6740292
>
> Modified:
> cfe/trunk/lib/Headers/limits.h
>
> Modified: cfe/trunk/lib/Headers/limits.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/limits.h?rev=68169&r1=68168&r2=68169&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Headers/limits.h (original)
> +++ cfe/trunk/lib/Headers/limits.h Tue Mar 31 19:44:37 2009
> @@ -96,4 +96,19 @@
> #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
> #endif
>
> +/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension.
> It's too bad
> + that we don't have something like #pragma poison that could be
> used to
> + deprecate a macro - the code should just use LLONG_MAX and
> friends.
> + */
> +#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !
> defined(__STRICT_ANSI__)
> +
> +#undef LONG_LONG_MIN
> +#undef LONG_LONG_MAX
> +#undef ULONG_LONG_MAX
> +
> +#define LONG_LONG_MAX __LONG_LONG_MAX__
> +#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1LL)
> +#define ULONG_LONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
> +#endif
> +
> #endif /* __CLANG_LIMITS_H */
I don't feel terribly strongly about this, but I thought I'd mention
something:
This "extension" has the potential to break conforming code.
I understand that sometimes you really need to support such extensions
to ease porting pain from a legacy compiler. In this case the cost to
the client in changing from the non-standard LONG_LONG_MIN to the
standard LLONG_MIN is truly minimal. A global search/replace could
easily fix this in a minute, even if there are tens of thousands of
instances in a project that need to be changed. Such a change won't
cause ABI or API breakage to the client. And such a change will only
be required for code that is actually being recompiled: i.e. binaries
built with the old extension are just as valid. If you're recompiling
the source, you have access to it to change it.
Is it practical to ask the author of rdar://6740292 if there are
impediments to using LLONG_MIN?
-Howard
More information about the cfe-commits
mailing list