Code: /* ---------------------------------------------------------------------- * DECLARE your own open(), close(), addr(), and byte() routines here. * */
static int open1(), close1(), addr1(), byte1(); static int open2(), close2(), addr2(), byte2(); static int open3(), close3(), addr3(), byte3(); static int open4(), close4(), addr4(), byte4();
/* ---------------------------------------------------------------------- * ADD an entry to this table to register your * output format routines. Give your object format * a name to be specified with the -F option. * */
static int format; static struct { char *name; int (*e_open)(); int (*e_close)(); int (*e_addr)(); int (*e_byte)(); } formtab[] = { { "tdr", open1, close1, addr1, byte1 }, { "byte", open2, close2, addr2, byte2 }, { "od", open3, close3, addr3, byte3 }, { "srec2", open4, close4, addr4, byte4 }, { "srec3", open4, close4, addr4, byte4 }, { "srec4", open4, close4, addr4, byte4 } };
#define FORMTABSIZE (sizeof(formtab)/sizeof(formtab[0])) Hi,
Above the structure declared the function in structure. This sample code is picked from other sample project code. This sample project i took from net is not completed source and some of the .h and .c file is not included.
The call functions:
Code: (*formtab[format].e_open)(file,ftype,arg); (*formtab[format].e_close)(); (*formtab[format].e_addr)(a); (*formtab[format].e_byte)(b); The compiler show:-> error C267: 'function': requires ANSI-style prototype
How to declare the function? I already included initial define function prototype. I think my function prototype is wrong.
The attached file is the code. Please help me...
Thank you.
Please read the instructions on how to post source code: www.danlhenry.com/.../keil_code.png
Note that TABs don't work (well) - use spaces instead,
and don't forget to check it in the 'Preview'...
It looks like you are using function pointers: the Keil tools have serious issues with function pointers - you need to ensure that you thoroughly understand them before you continue!
Read this App Note: http://www.keil.com/appnotes/docs/apnt_129.asp
and search the Knowledgebase for "Function Pointer" before you do anything else...!
here is A COPY OF THe source code from the projekt.
Code: /* ---------------------------------------------------------------------- * DECLARE your own open(), close(), addr(), and byte() routines here. * */ static int open1(), close1(), addr1(), byte1(); static int open2(), close2(), addr2(), byte2(); static int open3(), close3(), addr3(), byte3(); static int open4(), close4(), addr4(), byte4(); /* ---------------------------------------------------------------------- * ADD an entry to this table to register your * output format routines. Give your object format * a name to be specified with the -F option. * */ static int format; static struct { char *name; int (*e_open)(); int (*e_close)(); int (*e_addr)(); int (*e_byte)(); } formtab[] = { { "tdr", open1, close1, addr1, byte1 }, { "byte", open2, close2, addr2, byte2 }, { "od", open3, close3, addr3, byte3 }, { "srec2", open4, close4, addr4, byte4 }, { "srec3", open4, close4, addr4, byte4 }, { "srec4", open4, close4, addr4, byte4 } }; #define FORMTABSIZE (sizeof(formtab)/sizeof(formtab[0]))
Hi,
Code: (*formtab[format].e_open)(file,ftype,arg); (*formtab[format].e_close)(); (*formtab[format].e_addr)(a); (*formtab[format].e_byte)(b);
The compiler show:-> error C267: 'function': requires ANSI-style prototype
Did you read what I said about function pointers?
Again, you need to understand the issues with function pointers in C51 before you do anything else!
As to function prototypes, that is a standard part of the ANSI 'C' language - nothing specifically to do with Keil nor the 8051. Any 'C' textbook will tell you about function prototypes...
pLEASE CAn you tell me wHAt is wrong ??????????????????????????????????????????????????????
First You need to prototype" you functions. "requires ANSI-style prototype" This is basic C
Second The Keil Compiler on the 8052 has issuses with function pointers. The functions may need to be declared reentrant. Look in the manual it explains the issues.
If you are a newbie you picked a difficult project to start. You are not going to get a simple answer for this.
The error message clearly tells you what is wrong: Prototypes are required for your functions, and you have failed to provide them!
You must provide the function prototypes - this is standard ANSI 'C'.
If you don't understand this, you have some basic study to do before you start messing with function pointers - in C51 or anything else!
the safestr way to break a leg is running UNLESS you first learned to crawl then learned to walk then and only then tried running.
Your code and question show clearly that you skipped the first 2 steps.
Put aside what you have, get the "getting started guide" and "the bible" and start crawling, then walking and then, and only then, come back with what you heve here.
Erik
See my post of 19-Sep-2007 01:43 in this thread: http://www.keil.com/forum/docs/thread10718.asp
Again, this is basic ANSI 'C' textbook stuff!