Cygwin c compiler and c99

Andy Koppe andy.koppe@gmail.com
Sun Oct 31 16:46:00 GMT 2010


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



More information about the Cygwin mailing list