all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Jan Djärv" <jan.h.d@swipnet.se>
To: Bruno Haible <bruno@clisp.org>
Cc: 9025@debbugs.gnu.org, Paul Eggert <eggert@cs.ucla.edu>,
	bug-gnulib@gnu.org
Subject: bug#9025: 24.0.50; gnulib defines intmax_t to int64_t on OSX, causes warnings and confusion.
Date: Sat, 09 Jul 2011 13:25:54 +0200	[thread overview]
Message-ID: <4E183AC2.2010103__44902.0960405052$1310210848$gmane$org@swipnet.se> (raw)
In-Reply-To: <201107091227.03099.bruno@clisp.org>



Bruno Haible skrev 2011-07-09 12.27:
> Jan Djärv writes:
>
>>> Somewhere in gnulib, intmax_t gets defined to int64_t thus causing
>>> compiler warnings and general confusion (the code says intmax_t but is
>>> really int64_t).  AFAIK, all versions of OSX have intmax_t.
>
> Please provide a reproducible test case, preferrably outside Emacs.

Outside Emacs is hard, since I don't know what code uses gnulib or how to use 
it standalone.

>
> Also, I don't understand what's the problem: intmax_t must be 64-bit on
> MacOS X. No compiler supports 128-bit integers, AFAIK. Can you explain?
>

See reply to Paul.
Basically intmax_t is long and int64_t is long long.  Same size though.

For example:

intmax_t x;
...
printf ("%jd", x);

gives a compiler warning:

warning: format ‘%jd’ expects type ‘intmax_t’, but argument 2 has type ‘int64_t’

The naive fix is to cast x:

printf ("%jd", (intmax_t)x);

but that don't work because intmax_t is a define to int64_t.

	Jan D.

> Paul Eggert wrote:
>> Which compiler and OS version are you using?
>>
>> Does the following (untested) patch to lib/stdint.in.h fix your problem?
>>
>> diff --git a/lib/stdint.in.h b/lib/stdint.in.h
>> index c44401f..0dd60b9 100644
>> --- a/lib/stdint.in.h
>> +++ b/lib/stdint.in.h
>> @@ -270,6 +270,11 @@ typedef unsigned long int gl_uintptr_t;
>>   /* Note: These types are compiler dependent. It may be unwise to use them in
>>      public header files. */
>>
>> +/* If the system defines INTMAX_MAX, assume that intmax_t works, and
>> +   similarly for UINTMAX_MAX and uintmax_t.  This avoids problems with
>> +   assuming one type where another is used by the system.  */
>> +
>> +#ifndef INTMAX_MAX
>>   #undef intmax_t
>>   #if @HAVE_LONG_LONG_INT@&&  LONG_MAX>>  30 == 1
>>   typedef long long int gl_intmax_t;
>> @@ -280,7 +285,9 @@ typedef long long int gl_intmax_t;
>>   typedef long int gl_intmax_t;
>>   # define intmax_t gl_intmax_t
>>   #endif
>> +#endif
>
> Untested patches are OK in simple areas. But in complex areas like stdint.in.h
> I would really like to understand the problem before applying any patch. That
> means, provide a reproducible sample (including all details about OS, compiler,
> compiler options), and show the preprocessing result (output of "$CC -E" or
> - even better - "$CC -E -dD") of the code that gives warnings.
>
> Bruno





  parent reply	other threads:[~2011-07-09 11:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4E1826ED.9020602@cs.ucla.edu>
2011-07-09 10:27 ` bug#9025: 24.0.50; gnulib defines intmax_t to int64_t on OSX, causes warnings and confusion Bruno Haible
2011-07-09 11:18 ` Jan Djärv
     [not found] ` <201107091227.03099.bruno@clisp.org>
2011-07-09 11:25   ` Jan Djärv [this message]
2011-07-09 22:06   ` Paul Eggert
2011-07-08 10:17 Jan Djärv
2011-07-09 10:01 ` Paul Eggert

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='4E183AC2.2010103__44902.0960405052$1310210848$gmane$org@swipnet.se' \
    --to=jan.h.d@swipnet.se \
    --cc=9025@debbugs.gnu.org \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.