Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C Structure (Keil Compiler)

Status
Not open for further replies.

Help

Advanced Member level 2
Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Visit site
Activity points
7,065
(char code * code *) keil

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.

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);

I'm using Keil compiler. I had tryed put this code in my compiler but compiler show few warning, ex:
WARNING L2: Reference Made to Unresolved External
SYMBOL: Byte1


How to remove the warning?

Please help me....

Thank you.
 

keil extern structure

Hello,

The same problem i too got in my programsand i solved it too.

This warning is ur calling the function, that functions may not included in ur program structure or ur calling the function the externally that may not included in ur program structure.
 

    Help

    Points: 2
    Helpful Answer Positive Rating
requires ansi-style prototype

Prabakaran said:
Hello,

The same problem i too got in my programsand i solved it too.

This warning is ur calling the function, that functions may not included in ur program structure or ur calling the function the externally that may not included in ur program structure.

Hi Prabakaran,

Ya, you are rite. Thank for remind me. I'm not include any functions in my program.

I try to include the function in my program.

Code:
static open1(File, Ftype, Arg) char File, Ftype, Arg;
{
 char f,t,a;

 f=File;
 t=Ftype;
 a=Arg;	
}	 

static close1(void)
{
	
}

static addr1(A) int A;
{
	idata int a;
	
	a=A;
}

static  byte1(B) int B;
{
	idata int b;
	
	b=B;	
}
...
..
// Call function..
....
..
(*formtab[0].e_open) (1,2,3);
(*formtab[0].e_close)(); 
(*formtab[0].e_addr)(4);
(*formtab[0].e_byte)(5);

Now the compiler show:-> error C267: 'function': requires ANSI-style prototype

How to declare function? I think my function prototype is wrong. :(
 

The type for the functions that you are using as members in the structure should be available in the file where you are using them.
 

static close1(void);
static close2(void);

include these lines before the main program then execute the program. Add all function prototype before the main progarm ---- void main()
 

Hi,

Yes, I already included initial define function prototype. It still the same.
The attached file is the code.

Thank you.
 

The byte function is defined in another file, an external file. You need to use the extern statement to let the compiler and linker know that it is a function that will be found at some point in another file. And that file needs to be included in the project.
 

Hi,

Ya, I already checked, the function only use within that .c file without using to other external file. This sample project i took from net is not completed source and some of the .h and .c file is not included.

I just want to learn how to manage the function in C structure. It's good sample that i found.

Please help me if you know how to call and create the function..

Thank you.
 

G'day Help

The problem you have here is in your function declarations

static close1(void)

There is no return type specified

static void close1(void)

on pre-ansi compilers this was allowed and it would assume an int return type.
I believe in the ANSI standard the return type has to be specified.

So add a void return type to your function declarations and prototypes and you should be right.


Darren J.
 

    Help

    Points: 2
    Helpful Answer Positive Rating
Hi,

Thanks Darren J for your advice. I'm thought my topic would be stop until there. :(

Ya, you are rite. I already tested, the pre-ansi compiler would return the int data type.

So i have modified the code, make the code more specify on declaration type but the compiler still show error message 'function': requires ANSI-style prototype .
Please adivce me...

Thank alot.
 

Looks like you are using K&R style of function declaration. I am not sure about Keil compiler. But all the ANSI compiler will report error for it.

You need to use ANSI style of declaration.
eg. instead of
Code:
static open1(File, Ftype, Arg) char File, Ftype, Arg;
{
 char f,t,a;

 f=File;
 t=Ftype;
 a=Arg;   
}
you have to write

Code:
static open1(char File, char Ftype, char Arg)
{
......your code
}
you have to do it for all your functions.
 

Hi,

Actually static open1(File, Ftype, Arg) char File, Ftype, Arg; = static open1(char File, char Ftype, char Arg)

We still no solve the problem. :(
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top