0

这是错误:

msp430-gcc -mmcu=msp430g2553 -Os   -c -o gpio_test.o gpio_test.c
In file included from msp430_lib.h:9:0,
                 from gpio_test.c:4:
gpio_api.h:20:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gpio_init’
gpio_api.h:27:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gpio_ioctl_pull_en’
gpio_api.h:35:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gpio_write’
make: *** [gpio_test.o] Error 1

这是错误来自的头文件(行号不匹配,因为我从文件中删除了所有注释以缩短它):

/* gpio_api.h - General Purpose Input/Output API
*/

#ifndef MSP_GPIO_API_H
#define MSP_GPIO_API_H

#include  <msp430g2553.h>

#define INPUT   0
#define OUTPUT  1
#define DOWN    0
#define UP      1

bool gpio_init(int port, int pin, int direction);

bool gpio_ioctl_pull_en(int port, int pin, int direction);

bool gpio_write(int port, int pin, int value);

int  gpio_read (int port, int pin);

#endif

看起来很简单,但我无法弄清楚我的问题是什么。

4

1 回答 1

13

你必须包括<stdbool.h>在你的程序中。bool实际上是stdbool.h头文件中定义的宏。

于 2013-09-01T17:02:05.543 回答