Comment déclarer une variable globale
Bonjour,
une petite question concernant une variable globale. Est-il mieux de faire :
Code:
1 2 3
|
// ds PalIntern.h
extern volatile ST_HARD_REG *st_hard_reg; |
+
Code:
1 2 3
|
// ds main.c
volatile ST_HARD_REG *st_hard_reg=(ST_HARD_REG *)0xFFC00000; |
ou
Code:
1 2 3
|
// ds PalIntern.h
static volatile ST_HARD_REG *st_hard_reg=(ST_HARD_REG *)0xFFC00000; |
Evidemment PalIntern.h est inclut dans les fichiers ou j'ai besoin de st_hard_reg.
Merci d'avance.
Re: Probleme avec variable globale
Citation:
Envoyé par davkick
une petite question concernant une variable globale. Est-il mieux de faire :
Code:
1 2 3
|
// ds PalIntern.h
extern volatile ST_HARD_REG *st_hard_reg; |
+
Code:
1 2 3
|
// ds main.c
volatile ST_HARD_REG *st_hard_reg=(ST_HARD_REG *)0xFFC00000; |
Oui, à condition d'inclure "PalIntern.h" dans main.c
Citation:
ou
Code:
1 2 3
|
// ds PalIntern.h
static volatile ST_HARD_REG *st_hard_reg=(ST_HARD_REG *)0xFFC00000; |
Non (multiplication inutile d'une variable).