Eliah Ninyo wrote in message <[EMAIL PROTECTED]>... > >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:
And here is what I sent in response to that e-mail ... Comments below -- -Richard M. Hartman [EMAIL PROTECTED] 186,000 mi./sec ... not just a good idea, it's the LAW! > -----Original Message----- > From: Eliah Ninyo [mailto:[EMAIL PROTECTED] > Sent: Tuesday, November 14, 2000 12:50 AM > To: [EMAIL PROTECTED] > Subject: Re: i have problem with my project... > > > 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)??? need? no. just a matter of organization. > > 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?? a typedef is fine. > > 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. since "fp" is declared in a header file, are you certain that the file that "func1()" is in is including that header file? also: the keyword "static" means "make this private to this compilation unit". if that declaration is in a header file, what you will end up with is each .c file that includes that header will have it's own private variable named "fp" ... I am sure that you want a global. however if you just declare fp in the header file then each compilation unit will have it's own _non-private_ copy, and the linker will complain about multiple definitions of "fp"! So what's a guy to do? "extern" says "recognize this variable, but don't allocate any space for it. you should be have : extern mystruct *fp; in the header file. this lets all of the compilation units know there is a variable named "fp" of type "pointer to mystruct" _somewhere_. it then falls to the linker to figure out where. now to make sure the linker has one to work with, in ONE .c file (usually the main one ... or perhaps one set aside just for the declaration of globals) you need the actual declaration -- the one that allocates the space for "fp": mystruct *fp; note: no "static", no "extern". > > 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; > ... That's not different names for one pointer, that's different pointers. Now since they are pointers, they could both be pointing to the same actual object ... but is that what you really want to be doing? Why have a global if you aren't going to use it? I would suggest ditching "cv" and just use "fp" everywhere. > > ????? > > i hope u can help me by answering my questions because i really don't > understand what happening here. This isn't Palm stuff, this is basic C. It sounds like you need to find a good basic course on programming in C. Check your local computer bookstore, or there are some sites on the internet that offer introductory C programming tutorials. > > 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. occaisional mail would be ok. but before you need help programming for the Palm you seem to need help programming in C in general. you might want to attend to that first. -- -Richard M. Hartman [EMAIL PROTECTED] 186,000 mi/sec: not just a good idea, it's the LAW! -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
