- 论坛徽章:
- 0
|
//源文件test_attribute.c
extern void myprint(const char *format,...) __attribute__((format(printf,1,2)));
void test()
{
myprint("i=%d\n",6);
myprint("i=%s\n",6);
myprint("i=%s\n","abc"
myprint("%s,%d,%d\n",1,2);
}
int main(int argc,char **argv)
{
test();
}
//编译test_attribute.c
arm-uclinux-gcc -DDEBUG -Wall -Os -fstrict-aliasing -msoft-float -march=armv5 - mtune=arm926ejs -mapcs-32 -fomit-frame-pointer -c test_attribute.c -o te st_attribute.o
test_attribute.c: In function `test':
test_attribute.c:11: warning: format argument is not a pointer (arg 2)
test_attribute.c:15: warning: format argument is not a pointer (arg 2)
test_attribute.c:15: warning: too few arguments for format
test_attribute.c: In function `main':
test_attribute.c:22: warning: control reaches end of non-void function
arm-uclinux-gcc -Wl,-elf2flt='-s 4000' -Os -msoft-float -march=armv5 -mtune=ar m926ejs -mapcs-32 -fomit-frame-pointer -o test_attribute test_attribute.o
test_attribute.elf2flt(.text+0xc: In function `test':
: undefined reference to `myprint'
test_attribute.elf2flt(.text+0xd4): In function `test':
: undefined reference to `myprint'
test_attribute.elf2flt(.text+0xe0): In function `test':
: undefined reference to `myprint'
test_attribute.elf2flt(.text+0xf4): In function `test':
: undefined reference to `myprint'
collect2: ld returned 1 exit status
make: *** [test_attribute] Error 1
//问题
编译的时候为什么会提示:test_attribute.elf2flt(.text+0xc: In function `test':
: undefined reference to `myprint'了?
myprint()函数前面已经声明了啊? |
|