自添加组件问题
有人会在自添加组件中,头文件里面*_INSTANCE and *_INIT
宏的定义吗?我模仿IDE中UART的写法,编辑工程的时候alt_sys_init.c总是报错自添加设备名没有声明
自添加设备名为CANA
在opencores_can.h中结构体的声明
typedef struct opencores_can_dev_s
{
alt_dev dev;
alt_u32 base;
}opencores_can_dev;
宏定义为
#define OPENCORES_CAN_INSTANCE(name, device) \
static opencores_can_dev device = \
{ \
{ \
ALT_LLIST_ENTRY, \
name##_NAME, \
NULL, /* open */ \
NULL, /* close */ \
NULL, /* read */ \
NULL, /* write */ \
NULL, /* lseek */ \
NULL, /* fstat */ \
NULL, /* ioctl */ \
}, \
name##_BASE \
}
#define OPENCORES_CAN_INIT(name, dev) \
{ \
if (name##_IRQ == ALT_IRQ_NOT_CONNECTED) \
{ \
ALT_LINK_ERROR ("Error: Interrupt not connected for " #dev ". " \
"interrupt is not connected for this device."); \
} \
else \
opencores_can_init (&dev, name##_BASE); \
}
声明外部函数
extern void opencores_can_init (opencores_can_dev* dev, int base);
在opencores_can.c中定义函数暂时无操作
void opencores_can_init(opencores_can_dev* dev, int base)
{
}
结构编译时生成alt_sys_init.c出现
OPENCORES_CAN_INSTANCE( CANA, cana );
OPENCORES_CAN_INIT( CANA, cana );
但是报错
**** Incremental build of configuration Debug for project can_test ****
make -s all
Compiling alt_sys_init.c...
In file included from system_description/alt_sys_init.c:64:
/cygdrive/d/can_system/opencores_can/HAL/inc/opencores_can.h:42:33: warning: no newline at end of file
system_description/alt_sys_init.c:72: warning: type defaults to `int' in declaration of `OPENCORES_CAN_INSTANCE'
system_description/alt_sys_init.c:72: warning: parameter names (without types) in function declaration
system_description/alt_sys_init.c:72: warning: data definition has no type or storage class
system_description/alt_sys_init.c: In function `alt_sys_init':
system_description/alt_sys_init.c:82: warning: implicit declaration of function `OPENCORES_CAN_INIT'
system_description/alt_sys_init.c:82: error: `CANA' undeclared (first use in this function)
system_description/alt_sys_init.c:82: error: (Each undeclared identifier is reported only once
system_description/alt_sys_init.c:82: error: for each function it appears in.)
system_description/alt_sys_init.c:82: error: `cana' undeclared (first use in this function)
make[1]: *** [obj/alt_sys_init.o] Error 1
make: *** [system_project] Error 2
Build completed谢谢大家帮忙看看,急!我qq:123724607
[此贴子已经被作者于2007-1-17 13:48:01编辑过]
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |