This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin c compiler and c99


On 31 October 2010 14:39, David wrote:
> By adding #include <stdbool.h> it worked.
>
> Den 31-10-2010 14:45, Tim Prince skrev:
>>
>> On 10/31/2010 6:21 AM, David wrote:
>>>
>>> Does Cygwin c compiler not support c99?
>>> or does c99 not support?:
>>>
>>> #include <stdio.h>
>>> #include <stdlib.h>
>
> #include <stdbool.h>
>>>
>>> int main(void) {
>>> bool f=true;
>>> for(int i=0; i<10; i++) {
>>> if (f)
>>> printf("%d\n",i);
>>> }
>>> puts("Hello World!!!"); /* prints Hello World!!! */
>>> return EXIT_SUCCESS;
>>> }
>>>
>
>
> But why do I have to include <stdbool.h>?

Because 'bool', 'true' and 'false' are not defined in the C99
language, but in the C99 library, as macros in the stdbool.h header.
The language only defines the type _Bool with vaues 0 and 1.

See also:
http://www.codinghorror.com/blog/2008/03/the-first-rule-of-programming-its-always-your-fault.html

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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