public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Ada type in binding for C99 bool
@ 2009-09-21 20:04 Joel Sherrill
  2009-09-22 17:05 ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Sherrill @ 2009-09-21 20:04 UTC (permalink / raw)
  To: gcc

Hi,

What is the proper type to use in an Ada binding
for a C method that returns a C99 bool?

This appears to be an issue in s-stchop-rtems.adb
where it binds to the C routine:

bool rtems_stack_checker_is_blown( void )

Thanks.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985


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

* Re: Ada type in binding for C99 bool
  2009-09-21 20:04 Ada type in binding for C99 bool Joel Sherrill
@ 2009-09-22 17:05 ` Florian Weimer
  2009-09-22 17:54   ` Joel Sherrill
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Weimer @ 2009-09-22 17:05 UTC (permalink / raw)
  To: Joel Sherrill; +Cc: gcc

* Joel Sherrill:

> What is the proper type to use in an Ada binding
> for a C method that returns a C99 bool?

Whatever the answer is, it should be used to define Interfaces.C.Bool.
(I don't know what GCC's options for representing _Bool are, sorry.)

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

* Re: Ada type in binding for C99 bool
  2009-09-22 17:05 ` Florian Weimer
@ 2009-09-22 17:54   ` Joel Sherrill
  2009-09-22 18:00     ` Gabriel Dos Reis
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joel Sherrill @ 2009-09-22 17:54 UTC (permalink / raw)
  To: Florian Weimer; +Cc: gcc

Florian Weimer wrote:
> * Joel Sherrill:
>
>   
>> What is the proper type to use in an Ada binding
>> for a C method that returns a C99 bool?
>>     
>
> Whatever the answer is, it should be used to define Interfaces.C.Bool.
> (I don't know what GCC's options for representing _Bool are, sorry.)
>
>   
It appears to be unsigned char or at least sizeof(bool)=1
on the architectures I tried this test program on.

#include <stdbool.h>

bool x;
int s = sizeof(bool);

Unfortunately bool is defined to _Bool and that must be
something gcc recognizes.  I don't see it in .h files.

So I am only slightly more sure of it than you are. :)

--joel

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

* Re: Ada type in binding for C99 bool
  2009-09-22 17:54   ` Joel Sherrill
@ 2009-09-22 18:00     ` Gabriel Dos Reis
  2009-09-22 18:21     ` Florian Weimer
  2009-09-22 19:03     ` Joseph S. Myers
  2 siblings, 0 replies; 6+ messages in thread
From: Gabriel Dos Reis @ 2009-09-22 18:00 UTC (permalink / raw)
  To: Joel Sherrill; +Cc: Florian Weimer, gcc

On Tue, Sep 22, 2009 at 12:54 PM, Joel Sherrill
<joel.sherrill@oarcorp.com> wrote:
> Florian Weimer wrote:
>>
>> * Joel Sherrill:
>>
>>
>>>
>>> What is the proper type to use in an Ada binding
>>> for a C method that returns a C99 bool?
>>>
>>
>> Whatever the answer is, it should be used to define Interfaces.C.Bool.
>> (I don't know what GCC's options for representing _Bool are, sorry.)
>>
>>
>
> It appears to be unsigned char or at least sizeof(bool)=1
> on the architectures I tried this test program on.
>
> #include <stdbool.h>
>
> bool x;
> int s = sizeof(bool);
>
> Unfortunately bool is defined to _Bool and that must be
> something gcc recognizes.  I don't see it in .h files.

C99 Boolean type is _Bool.  C99 requires people to
include <stdbool> if they want to write bool instead of _Bool.

>
> --joel
>

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

* Re: Ada type in binding for C99 bool
  2009-09-22 17:54   ` Joel Sherrill
  2009-09-22 18:00     ` Gabriel Dos Reis
@ 2009-09-22 18:21     ` Florian Weimer
  2009-09-22 19:03     ` Joseph S. Myers
  2 siblings, 0 replies; 6+ messages in thread
From: Florian Weimer @ 2009-09-22 18:21 UTC (permalink / raw)
  To: Joel Sherrill; +Cc: gcc

* Joel Sherrill:

>> Whatever the answer is, it should be used to define Interfaces.C.Bool.
>> (I don't know what GCC's options for representing _Bool are, sorry.)

> It appears to be unsigned char or at least sizeof(bool)=1
> on the architectures I tried this test program on.

That's only half of the story.  The other half are the possible values
of *(char *)&x for some variable of type _Bool, and what the value of
(int)x is in those cases.

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

* Re: Ada type in binding for C99 bool
  2009-09-22 17:54   ` Joel Sherrill
  2009-09-22 18:00     ` Gabriel Dos Reis
  2009-09-22 18:21     ` Florian Weimer
@ 2009-09-22 19:03     ` Joseph S. Myers
  2 siblings, 0 replies; 6+ messages in thread
From: Joseph S. Myers @ 2009-09-22 19:03 UTC (permalink / raw)
  To: Joel Sherrill; +Cc: Florian Weimer, gcc

On Tue, 22 Sep 2009, Joel Sherrill wrote:

> It appears to be unsigned char or at least sizeof(bool)=1
> on the architectures I tried this test program on.

The size is determined by BOOL_TYPE_SIZE (and is not 1 byte for 
powerpc-darwin).

-- 
Joseph S. Myers
joseph@codesourcery.com

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

end of thread, other threads:[~2009-09-22 19:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-21 20:04 Ada type in binding for C99 bool Joel Sherrill
2009-09-22 17:05 ` Florian Weimer
2009-09-22 17:54   ` Joel Sherrill
2009-09-22 18:00     ` Gabriel Dos Reis
2009-09-22 18:21     ` Florian Weimer
2009-09-22 19:03     ` Joseph S. Myers

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