c program assign an int to a bool? -


i'm programming mcu. description of gpio_read_pin() function. returns bool.

can assign int ack? , test if ack 0 or 1?

thanks

/**  * read current value of single pin on given gpio port.  *  * @param[in] gpio gpio port index.  * @param[in] pin pin of gpio port read.  * @return bool value of pin specified on gpio port.  */ bool gpio_read_pin(const gpio_t gpio, const uint8_t pin);    void sendcommandsht(int command) {    ...    int ack;    ack = gpio_read_pin(qm_gpio_0, data_pin);    if (ack != 0) {       ti_puts("ack error 0");   } } 

original c doesn't have bool type. however, it's defined as:

typedef enum { false = 0, true = 1 } bool;

can assign int ack? , test if ack 0 or 1?

so q - yes.


in c99 bool type exists, using <stdbool.h>


Comments