Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

errors of using bool type in program

when i tried to define a bool type data or use bool type as my function's parameter,there is many error messages displayed in the concole.

like this:

../hello_world.c:23: error: `bool' undeclared (first use in this function)

../hello_world.c:23: error: (Each undeclared identifier is reported only once

../hello_world.c:23: error: for each function it appears in.)

../hello_world.c:23: error: syntax error before "b"

i figured that the compiler recognised bool as a valid data type since it is highlighted the same as other types.

How to fix that?

ps:i only include <stdio.h>in my program.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You need to include stdbool.h as well.

    The editor probably has a different list of known typenames.

    OTOH the compiler will generate better code if you avoid 'bool'.