Re: C Question: TypeDefing a structure ?
Hello Igor,
Yes I do understand the difference, however my compiler gives me an error if
I don't include the .c file which contains the funtion implementations, The
error is somewhere along the lines of:
"Function used but not defined ... ULC_DDLB_LIB_config_DDLB SCR=4341"
which means that it doesn't see the implementation file I guess!
BUT! I did see a "multiple compilation units" and "link seperately" check
boxes in a project option screen of my compiler and when I checked off these
boxes, I was able to leave the header includes and remove all the includes to
all .c files in ACM152.c and successfully compiled without said errors. So I
will make sure that this is the meaning of those check boxes and if so, I
will switch to your way!
Anyhow, there was a typo in my code. It should of been DDLB instead of DDBL
!!!!
see code below:
=============================================
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)); should of been:
obj_DDLB = (DDLB*) malloc (sizeof (struct ddListBox));
case e_MODIFY:
//obj_DDBL->CURR_ICON_NUM= CURR_ICON_NUM; should of been:
obj_DDLB->CURR_ICON_NUM= CURR_ICON_NUM;
//return obj_DDBL; should of been
return obj_DDLB;
break;
case e_FREE:
//free(obj_DDBL); should of been:
free(obj_DDLB);
break;
}
}
===========================================
Thankyou all for your feedback, it was very appreciated! Also all of your
coding reccomendations are always welcome and important to me!
--
Best regards
Robert
"Igor Tandetnik" wrote:
"Robby" <Robby@discussions.microsoft.com> wrote in message
news:B814C26D-FA23-44FD-AB5E-2BED1FE9B475@microsoft.com
Hello, Igor. I was told to include the header files seperately and
not to include header files in their associated .c files. For
example I was taught not to do this:
=====main.c
#include <xxx.c>
code....
=========
And rightly so.
rather I was taught to do this:
=====main.c
#include <xxx.h>
#include <xxx.c>
code....
=========
Either you were taught wrong, or you misunderstood the lesson. The usual
setup goes like this:
======xxx.h
declarations...
=========
======xxx.c
#include <xxx.h>
code...
===========
=====main.c
// Note - include the header, not the source.
#include <xxx.h>
code....
=========
Explain me something. Whats wrong with having your main .c file
include all the header files that contain declarations for their
respective .c files?
Nothing. It's including the _implementation_ files that's unusual. Do
you understand the difference?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925