i sent the same email to u directly, but incase u didn't see it or other one
want to help too here it is again:

hello,
i just see what u wrote to me and i have couple of questions.
you say that i need a specific header file for my structure (structdef.h)
and other one for my global variables (globals.h)???

i define my structure as typedef so the syntax should look like that:
 typedef struct
{
 int field1;
 char field2[80];
}
mystruct;

(- and not like u wrote down the email)
is it correct??

another thing is that the compiler pass the line that i declare the pointer
to my struct (which located at the header file) which look like that:

static mystruct    *fp;

but it got stuck when i have a function like that:

CharPtr func1 (void)
{
 return fp -> field1;   // field1 is defined as above
}

it give me an error saying that "identifier expected", it's like it doesn't
recognize the "fp -> field1" as a value variable.

another thing is that i use diffrent names for my struct poiter in file1 and
in file2. on the first it called *cv and at the secound it called *fp. so do
i need to add in my globals.h this lines:

...
extern struct mystruct *fp,*cv;
...

?????

i hope u can help me by answering my questions because i really don't
understand what happening here.

one last thing is that i want to ask u if i can sometimes send u a direct
email to ask u questions because i really need someone helping me sometimes
in this palm programming thing. if u don't want me to send u direct email so
just say so, everything will be ok no harm feeling.

tnx for your answer and i hope to here from u soon,

byeeee :-)

"Richard M. Hartman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Your message tells me you have a fundamental lack of
> understanding about variables.
>
> A variable is a symbol that you declare to the compiler
> as pointing to some chunk of information.  That chunk
> could just as easily be a struct as it could one of the
> primitive data types like int or char.  There is nothing
> that restricts the use of extern to primitive data types.
>
>
> FILE: structdef.h
>
> struct mystruct {
>     int field1;
>     char field2[80];
> };
>
>
> FILE: globals.h
> #include "structdef.h"
> extern struct mystruct mystructvar;
>
> FILE: main.c
>
> #include "structdef.h"
> #include "globals.h"
>
> /* note: must allocate storage for extern var declared in "globals.h" */
> struct mystruct mystructvar;
>
> int func1() {
>     StrCopy(mystructvar.field2, "using function func1() from file
main.c");
> }
>
> FILE: other.c
>
> #include "structdef.h"
> #include "globals.h"
>
> int func2() {
>     StrCopy(mystructvar.field2, "using function func2() from file
other.c");
> }
>
>
> --
> -Richard M. Hartman
> [EMAIL PROTECTED]
>
> 186,000 mi/sec: not just a good idea, it's the LAW!
>
>
> Eliah Ninyo wrote in message <[EMAIL PROTECTED]>...
> >
> >hi,
> >
> >i use a structure not a varible so i cann't use extern.
> >i have a project with two files, when i put the typedef and define the
> >structure fields in the second file i get an errors about a structure
> >declaration. but when i declare another struct it's ok.
> >
> >it looks like it has something with my structure.
> >for more details email me.
> >
> >byeee :-)
> >"Charles Rezsonya" <[EMAIL PROTECTED]> wrote in message
> >news:[EMAIL PROTECTED]
> >>
> >> hey,  why is it that a global shouldn't be shared across files? via
> >extern?
> >> i do this occasionally but haven't seen or heard issues with this (or
> >> atleast what i seen).
> >>
> >> tia
> >> Charles R
> >>
> >> -----Original Message-----
> >> From: Fitzpatrick, Joe <[EMAIL PROTECTED]>
> >> To: Palm Developer Forum <[email protected]>
> >> Date: Monday, November 06, 2000 6:51 PM
> >> Subject: RE: i have problem with my project...
> >>
> >>
> >> >I'm not completely sure I understand you problem - but here are some
> >> >generalities:
> >> >
> >> >If you are create a new data type (typdef or C++ class), the
definition
> >has
> >> >to be included by all source files that use the type.  So, generally
the
> >> >definition goes in a shared .h file.
> >> >
> >> >If you are sharing a global variable between files (not a great idea,
> but
> >> >that is a huge subject) ONE source file (.c/.cpp) must instantiate the
> >> >variable, all other source files that need the variable must include
an
> >> >'extern' declaration for the variable.
> >> >
> >> >File1.cpp:
> >> >   mytype MyPublicVariable;
> >> >
> >> >File2.cpp:
> >> >   extern mytype MyPublicVariable;
> >> >
> >> >There are games you can play with header files and defines to cut down
> on
> >> >repetition but, from the compiler's point of view the situation
remains
> >the
> >> >same.
> >> >
> >> >Good Luck,
> >> >-jjf
> >> >
> >> >-----Original Message-----
> >> >From: Eliah Ninyo [mailto:[EMAIL PROTECTED]
> >> >Sent: Sunday, November 05, 2000 1:08 PM
> >> >To: Palm Developer Forum
> >> >Subject: i have problem with my project...
> >> >
> >> >
> >> >hello,
> >> >
> >> >i have a project with two files: file1.cpp and file2.cpp. i also have
a
> >> >header file, lets call it hand.h (in addition for the resources header
> >> >file).
> >> >
> >> >i define a type def structure at file1. i needed the structure to be
> >known
> >> >at file2, so i put it un my header file - hand.h.
> >> >i have in file2 line code in one of my function that looks like that:
> >> >
> >> >return strctP->field;
> >> >
> >> >strctP is define like this:
> >> >
> >> >mystructure *strctP;  // as a pointer to my structure
> >> >
> >> >field is one of the field in my struct.
> >> >
> >> >for some resone i get an error on this line (  - "return ...") saying
"
> >> >identifier expected".
> >> >
> >> >i really don't know what to do, why doesn't the '->' work?
> >> >
> >> >
> >> >by the way, i use Code Warrior 6R.
> >> >
> >> >i hope some1 will know the answer because i real stuck.
> >> >
> >> >tnx :-)
> >> >byeeeee
> >> >
> >> >
> >> >--
> >> >ELIAH NINYO
> >> >
> >> >[EMAIL PROTECTED]
> >> >
> >> >  ("`-''-/").___..--''"`-._
> >> >  `6_ 6  )   `-.  (     ).`-.__.`)
> >> >   (_Y_.)'  ._   )  `._ `. ``-..-'
> >> > _..`--'_..-_/  /--'_.' ,'
> >> >(il).-''  (li).'  ((!.-'
> >> >
> >> >
> >> >
> >> >--
> >> >For information on using the Palm Developer Forums, or to unsubscribe,
> >> >please see http://www.palmos.com/dev/tech/support/forums/
> >> >
> >> >--
> >> >For information on using the Palm Developer Forums, or to unsubscribe,
> >> please see http://www.palmos.com/dev/tech/support/forums/
> >> >
> >>
> >>
> >>
> >
> >
> >
> >
>
>
>
>





-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to