Re: C Question: TypeDefing a structure ?
My guess is that your unnamed C compiler gets confused by the argument name
in ULC_DDLB_LIB_do_DDLB function declaration.
"Robby" <Robby@discussions.microsoft.com> wrote in message
news:8FD11D01-4D18-476F-81AC-CFF86AE07F26@microsoft.com...
Hello,
I have recently created my own way of manipulating the informations in a
structure and has worked very well.... until today! I am sure many
individuals had this idea and at one point or another tried this or even
adopted it.. it really is a no brainer.
I don't know... perhaps this is not the way to do things, however, it did
work for several structures in my project but this last structure has
generated errors. I have tried dozens of tests, but can't seem to find the
source of the errors. The other four structures in my project (not shown
here, however are an exact carbon copy only different names) are
manipulated
this way and are flawless in terms of functionality, errors or warning
messages.
Basically, I typedef a structure and create a global pointer of the that
type (which is of the structure's type) and then when I want to create an
object of that structure, I fecth a function which creates the object on
the
heap using malloc. The function accepts an object command parameter which
tells how the logic in the function is to be executed. Basically the
function
either creates, modifies or frees the object's data.
The errors that are generated are:
Line 10 (16,24) Unidefined identifier obj_DDLB
Line 13 ( 7,15) Unidefined identifier obj_DDLB
Line 14 (14,22) Unidefined identifier obj_DDLB
Line 18 (12,20) Unidefined identifier obj_DDLB
How can this be when "obj_DDLB" is declared globally?????
These are the errors that my MCU's compiler generates.
Thanking everyone in advance as all feedback and help is very, very
appreciated!
Here is the sample code:
==============================================ACM152.h
enum OBJECTTASK {e_CREATE=1, e_MODIFY, e_FREE};
==============================================ACM152.c
#include <ACM152.h>
#include <API_DDLB_LIB.h>
#include <API_DDLB_LIB.c>
void main()
{
obj_DDLB = ULC_DDLB_LIB_config_DDLB (e_CREATE, 0);
ULC_DDLB_LIB_do_DDLB(obj_DDLB);
ULC_DDLB_LIB_config_DDLB (e_FREE, 0);
}
==========================================API_DDLB_LIB.h
typedef struct ddListBox{
long CURR_ICON_NUM;
} DDLB;
DDLB *obj_DDLB;
DDLB* ULC_DDLB_LIB_config_DDLB
( int OBJECT_CONTROL,
long CURR_ICON_NUM);
void ULC_DDLB_LIB_do_DDLB (DDLB *obj_DDLB);
==========================================API_DDLB_LIB.c
DDLB* ULC_DDLB_LIB_config_DDLB(
int OBJECT_CONTROL,
long CURR_ICON_NUM)
{
switch (OBJECT_CONTROL)
{
case e_CREATE:
obj_DDBL = (DDLB*) malloc (sizeof (struct ddListBox));
case e_MODIFY:
obj_DDBL->CURR_ICON_NUM= CURR_ICON_NUM;
return obj_DDBL;
break;
case e_FREE:
free(obj_DDBL);
break;
}
}
void ULC_DDLB_LIB_do_DDLB( DDLB *obj_DDLB)
{//NO CODE }
===================================================
--
Best regards
Robert