In the .h file that is included by both, put in "extern UInt16 SerialRefNum;", then put the actual "UInt16 SerialRefNum;" in _only_ one of the .c files (wherever it seems to fit best; which file you declare it in is really just a style question, and won't affect functionality).
-Thomee Wright- "Andrew Lathrop" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Thanks Thomee. That did appear to be my error. Another question on the > same topic, how do i use variables between the modules? For instance, i > create UInt SerialRefNum in the main.c file. I then need to use it in the > char.c file. If i declare it again in the char.c file, the compiler tells > me it was already declared in main.c. If i don't, it says the variable was > an undefined identifier. I tried to delcare it in a header file that was > included in both c files, but i then got an incorrect use of header message. > Any ideas? Thanks > Andrew > Thomee Wright <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > I can't see any problems with it right off, but your description of the > > error was pretty vague. If you could include the actual text of the error > > message (esp. line numbers), that would help. A problem that it looks > like > > you haven't seen yet but will is that chars.c needs to include any > relevant > > .h files as well, or you will get errors when trying to call any PalmOS > > function, and when trying to refer to any of your resources that are > defined > > in Test_res.h. (Maybe this is your problem, and I just misunderstood your > > description of the error). > > > > -Thomee Wright- > > > > "Andrew Lathrop" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > > > > Im trying to split my larger program into several modules. I know you > need > > > to make the header file, and then include the header in both the main c > > file > > > and the file you made the header for. I can't get mine to quite work out > > > right. I have tried changing the declarations in the header to extern, > > > removing the identifiers, and other things i cna think of, but i still > get > > > errors. I enclosed the header file, as well as the c file. The way it > > > currently is, i get error messages looking for a ) in the declarations > in > > > the header after the identifier, and that it is looking for an identifer > > > after the closing ) that already is there. Any advice is greatly > > > appreciated. Thanks > > > Andrew > > > > > > (HEADER FILE) > > > #ifndef CHARS_H > > > #define CHARS_H > > > ///// > > > // chars.h > > > ///// > > > > > > void send_char( Byte p ); > > > Byte recv_char(); > > > > > > #endif > > > > > > (C FILE) > > > ///// > > > // chars.c > > > ///// > > > > > > #include "chars.h" > > > > > > // void send_char( Byte p ); > > > > > // Byte recv_char( ); > > > > > > void send_char( Byte p ) > > > { > > > Err e; > > > > > > SerSend(SerialRefNum, &p, 1, &e ); > > > if( e ) > > > FrmCustomAlert( ErrorAlert, "Error", "", "" ); > > > } > > > > > > Byte recv_char( ) > > > { > > > Err e; > > > Byte f; > > > > > > SerReceive(SerialRefNum,&f,1,0,&e); > > > if( e ) > > > FrmCustomAlert( ErrorAlert, "Error", "", "" ); > > > > > > return( f ); > > > } > > > > > > (MAIN.C) > > > #include <Pilot.h> > > > #include <Graffiti.h> > > > #include <SysEvtMgr.h> > > > #include <SerialMgr.h> > > > #include "Test_res.h" > > > #include "chars.h" > > > ... > > > > > > > > > > > > > > > > > > > > > > > > -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
