|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Sep 2008
Città: Messina
Messaggi: 991
|
[C] Visibilità variabili globali su header file
Un pò di tempo fa avevo fatto una mia prima versione del gioco del sette e mezzo però, ripreso il codice, mi sono accorto fosse un pò confusionario e di non facile comprensione. Negli ultimi giorni ho passato il tempo a dividerlo in più file ed header file.
Sembra tutto funzionare tranne che per un particolare: in due header file vi sono delle funzioni che usano delle variabili globali inserite nel file "main.c" e queste variabili non vengono rilevate completamente. Codice:
In file included from main.c:13: extration.h: In function ‘ChiamaCartaNascosta’: extration.h:26: error: ‘CardUser’ undeclared (first use in this function) extration.h:26: error: (Each undeclared identifier is reported only once extration.h:26: error: for each function it appears in.) extration.h:27: error: ‘secretScoreUser’ undeclared (first use in this function) extration.h:29: error: ‘ScoreUser’ undeclared (first use in this function) extration.h: In function ‘ChiamaCartaUtente’: extration.h:41: error: ‘CardUser’ undeclared (first use in this function) extration.h:42: error: ‘tempScoreUser’ undeclared (first use in this function) extration.h:44: error: ‘ScoreUser’ undeclared (first use in this function) extration.h:44: error: ‘secretScoreUser’ undeclared (first use in this function) extration.h: In function ‘ChiamaCartaPc’: extration.h:56: error: ‘CardPc’ undeclared (first use in this function) extration.h:57: error: ‘ScorePc’ undeclared (first use in this function) In file included from main.c:14: score.h: In function ‘ControlloPunteggioUser’: score.h:24: error: ‘ScoreUser’ undeclared (first use in this function) score.h:26: error: ‘cont_pc’ undeclared (first use in this function) score.h: In function ‘ControlloPunteggioPc’: score.h:39: error: ‘ScorePc’ undeclared (first use in this function) score.h:41: error: ‘cont_utente’ undeclared (first use in this function) score.h:43: error: ‘ScoreUser’ undeclared (first use in this function) score.h:45: error: ‘cont_pc’ undeclared (first use in this function) Mi chiedo allora quali siano le regole di visibilità delle variabili globali. Non erano visibili a tutto il programma?! ![]()
__________________
PC/HTPC: Mac Mini 3,1 late 2009 | My Book Studio 2TB | LG M237WD monitor/tv | Logitech Z4 | Apple Magic Mouse | Apple Wireless Keyboard | Apple Remote Mobile: Samsung Galaxy Wonder i8150 cm9 |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Iscritto dal: Sep 2008
Città: Messina
Messaggi: 991
|
Quote:
![]()
__________________
PC/HTPC: Mac Mini 3,1 late 2009 | My Book Studio 2TB | LG M237WD monitor/tv | Logitech Z4 | Apple Magic Mouse | Apple Wireless Keyboard | Apple Remote Mobile: Samsung Galaxy Wonder i8150 cm9 |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 16:44.