Click here to Skip to main content
15,921,577 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to add button on listcontrol instead of scrollbar Pin
Hans Dietrich7-Apr-11 23:47
mentorHans Dietrich7-Apr-11 23:47 
Questionadd button to listcontrol Pin
rajniyadav1a7-Apr-11 21:53
rajniyadav1a7-Apr-11 21:53 
AnswerRe: add button to listcontrol Pin
Hans Dietrich7-Apr-11 21:58
mentorHans Dietrich7-Apr-11 21:58 
AnswerRe: add button to listcontrol Pin
«_Superman_»8-Apr-11 3:36
professional«_Superman_»8-Apr-11 3:36 
Questionadd button to listcontrol Pin
rajniyadav1a7-Apr-11 21:42
rajniyadav1a7-Apr-11 21:42 
AnswerRe: add button to listcontrol Pin
Hans Dietrich7-Apr-11 21:44
mentorHans Dietrich7-Apr-11 21:44 
QuestionLoading release Build bt not hybrid Pin
002comp7-Apr-11 20:28
002comp7-Apr-11 20:28 
AnswerRe: Loading release Build bt not hybrid Pin
Hans Dietrich7-Apr-11 21:42
mentorHans Dietrich7-Apr-11 21:42 
QuestionDynamic shared memory Pin
pandit847-Apr-11 19:35
pandit847-Apr-11 19:35 
QuestionHow can I read ODBC from registry ? Pin
_Flaviu7-Apr-11 9:59
_Flaviu7-Apr-11 9:59 
GeneralRe: How can I read ODBC from registry ? Pin
David Crow7-Apr-11 18:06
David Crow7-Apr-11 18:06 
GeneralRe: How can I read ODBC from registry ? Pin
_Flaviu7-Apr-11 19:14
_Flaviu7-Apr-11 19:14 
GeneralRe: How can I read ODBC from registry ? Pin
_Flaviu7-Apr-11 19:52
_Flaviu7-Apr-11 19:52 
QuestionWM_KICKIDLE Message and Cursor? Pin
Arrin7-Apr-11 4:37
Arrin7-Apr-11 4:37 
QuestionGlobal array question [modified] Pin
Cristoff6-Apr-11 23:48
Cristoff6-Apr-11 23:48 
AnswerRe: Global array question Pin
«_Superman_»7-Apr-11 0:18
professional«_Superman_»7-Apr-11 0:18 
GeneralRe: Global array question Pin
Cristoff7-Apr-11 0:30
Cristoff7-Apr-11 0:30 
GeneralRe: Global array question Pin
«_Superman_»7-Apr-11 0:34
professional«_Superman_»7-Apr-11 0:34 
GeneralRe: Global array question Pin
Cristoff7-Apr-11 0:59
Cristoff7-Apr-11 0:59 
AnswerRe: Global array question [modified] Pin
Luc Pattyn7-Apr-11 1:48
sitebuilderLuc Pattyn7-Apr-11 1:48 
int someMap[MAPSIZE_X][MAPSIZE_Y]; allocates memory for an array; if you include that statement in a header file, then include that header file in N different C files, you end up allocating N arrays, all with the same name, and the linker will complain as it can't have data blocks with global scope and conflicting names.

extern int someMap[MAPSIZE_X][MAPSIZE_Y]; says: "there is an array somewhere, but this by itself does not allocate it"; so inserting that in the header file tells your C files they get access to the array, without allocating memory at all, and without creating linker problems. Of course you still need a single int someMap[MAPSIZE_X][MAPSIZE_Y]; in one of the C files to actually allocate the memory; and that C file better also include the header file with the extern statement.

[ADDED]
One elegant way of dealing with all this is described in Stefan63's message below.
[/ADDED]

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Thursday, April 7, 2011 9:02 AM

GeneralRe: Global array question Pin
Cristoff8-Apr-11 0:14
Cristoff8-Apr-11 0:14 
GeneralRe: Global array question Pin
Luc Pattyn8-Apr-11 0:19
sitebuilderLuc Pattyn8-Apr-11 0:19 
AnswerRe: Global array question PinPopular
Stefan_Lang7-Apr-11 2:18
Stefan_Lang7-Apr-11 2:18 
GeneralRe: Global array question Pin
Albert Holguin7-Apr-11 3:51
professionalAlbert Holguin7-Apr-11 3:51 
GeneralRe: Global array question Pin
Cristoff8-Apr-11 0:16
Cristoff8-Apr-11 0:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.