avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] (no subject)


From: MuRaT KaRaDeNiZ
Subject: RE: [avr-gcc-list] (no subject)
Date: Mon, 30 Jan 2006 23:39:11 +0200

So

U08 RX485_oldbyte1; is uninitialized data, but compiler also initialize
it to zero, why is it different from inline initialization during
declaration, I expect the compiler just replace the zero with the
initial value i provide?

Regards

Murat Karadeniz
http://www.onlinefavbar.com/mukas


-----Original Message-----
From: Bob Paddock [mailto:address@hidden 
Sent: Monday, January 30, 2006 11:18 PM
To: MuRaT KaRaDeNiZ
Cc: 'AVR-GCC-list'
Subject: Re: [avr-gcc-list] (no subject)



You want something more like this:

#ifndef _GLOBAL_H_
#define _GLOBAL_H_ (1)

#ifdef  DEFINE_SPACE_GLOBAL_H
#define EXTERN_GLOBAL
#else
#define EXTERN_GLOBAL extern
#endif

#if defined(__cplusplus) && __cplusplus
  extern "C" {
#endif

EXTERN_GLOBAL u08 RX485_oldbyte3, RX485_oldbyte2, RX485_oldbyte1;

#if defined(__cplusplus) && __cplusplus
  }
#endif

#endif /* _GLOBAL_H_ */

Then in global.c put:

#define  DEFINE_SPACE_GLOBAL_H (1) /* This line goes in *ONLY* global.c!
*/ #include "global.h"

Now space will be allocated in global.c, but all other
files will get the proper 'extern'.

Do not put initialized data in a header file that is included in
multiple places.  In this example the initialized data belongs in
global.c .

You can ignore the cplusplus stuff, that is just how
I have my emacs templates setup.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]