Hi Dave, My header looks like this:
#ifndef GLOBAL_H #define GLOBAL_H u08 tx_packet_length=0; u08 header_ok=0; u08 RX485_oldbyte3, RX485_oldbyte2, RX485_oldbyte1; #endif I wait from conditional definition, that it protects from multiple definitions, and if I include the header, no extern should be needed, right? Still, u08 RX485_oldbyte3, RX485_oldbyte2, RX485_oldbyte1; //does not cause any error u08 tx_packet_length=0; u08 header_ok=0; //gives multiple definition error , when header is included in multiple project files My problem is still unanswered, what is this? Best Regards Murat Karadeniz http://www.onlinefavbar.com/mukas -----Original Message----- From: Dave Hylands [mailto:[EMAIL PROTECTED] Sent: Monday, January 30, 2006 9:30 PM To: MuRaT KaRaDeNiZ Cc: AVR-GCC-list Subject: Re: [avr-gcc-list] (no subject) Hi, Sending to list... > I live a problem with avr gcc: When i use a global variable in the > header file and simultaneously initialize it to nonzero value in the > declaration, then the use of this header file in multiple project > source files as an include causes "multiple definition error" on this > specific lines in the header file. Not initialized globals (by myself) > and defines do not cause any error. the whole header file content is > in a conditional define, in a regular manner, so i dont understand > what is going on. what is wrong? In the header file, you need to use the word extern. Putting: int x; says to allocate storage for an int sized variable named x. Since this is in a header file, every C file that includes the header file will try to create a variable named x, which is where the multiple declarations are coming from. Using: extern int x; says that somebody else has allocated storage for an int sized variable named x. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/ _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list