Click here to Skip to main content
15,910,471 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Access Global Variable. Pin
Luc Pattyn17-Jun-10 2:10
sitebuilderLuc Pattyn17-Jun-10 2:10 
GeneralRe: Access Global Variable. [modified] Pin
CPallini17-Jun-10 2:14
mveCPallini17-Jun-10 2:14 
GeneralRe: Access Global Variable. Pin
Luc Pattyn17-Jun-10 2:22
sitebuilderLuc Pattyn17-Jun-10 2:22 
GeneralRe: Access Global Variable. Pin
CPallini17-Jun-10 2:39
mveCPallini17-Jun-10 2:39 
GeneralRe: Access Global Variable. Pin
Luc Pattyn17-Jun-10 2:43
sitebuilderLuc Pattyn17-Jun-10 2:43 
AnswerRe: Access Global Variable. Pin
rp_suman16-Jun-10 23:49
rp_suman16-Jun-10 23:49 
GeneralRe: Access Global Variable. Pin
ThatsAlok16-Jun-10 23:52
ThatsAlok16-Jun-10 23:52 
AnswerRe: Access Global Variable. Pin
Aescleal17-Jun-10 0:00
Aescleal17-Jun-10 0:00 
The first response is to gently chide the interviewer telling him (or her) that they're mad for using global variables in a multi-threaded program.

Once they've made some excuse for using global data (legacy code, have to make change immediately otherwise the four horsemen ride, Jormangand wakes or even worse the company's stock price falls) the second thing to do is turn the question around and ask whether they mean from one thread at a time or only from one thread? If they say from only one thread EVER then say you'd use thread local storage (TLS) or refactor the code to pass the parameter down the call stack from the function the thread started in. If they "from one thread at a time" say you'd use the appropriate type of lock - usually a type of mutex.

The final thing before the interviewer moves on is to ask whether programmers use a lot of globals at this company... If they do consider asking for more money as you'll need it for the extra hours spent debugging gash code (and yes, this is from recent personal experience...)

Cheers,

Ash
GeneralRe: Access Global Variable. Pin
gothic_coder17-Jun-10 0:05
gothic_coder17-Jun-10 0:05 
Questioncasting between pointers Pin
Iosif Murariu16-Jun-10 21:33
Iosif Murariu16-Jun-10 21:33 
AnswerRe: casting between pointers Pin
«_Superman_»16-Jun-10 21:43
professional«_Superman_»16-Jun-10 21:43 
GeneralRe: casting between pointers Pin
Iosif Murariu16-Jun-10 21:50
Iosif Murariu16-Jun-10 21:50 
GeneralRe: casting between pointers Pin
«_Superman_»16-Jun-10 22:05
professional«_Superman_»16-Jun-10 22:05 
GeneralRe: casting between pointers Pin
Iosif Murariu16-Jun-10 22:10
Iosif Murariu16-Jun-10 22:10 
AnswerRe: casting between pointers Pin
Stephen Hewitt16-Jun-10 21:56
Stephen Hewitt16-Jun-10 21:56 
AnswerRe: casting between pointers Pin
Code-o-mat16-Jun-10 22:08
Code-o-mat16-Jun-10 22:08 
GeneralRe: casting between pointers Pin
Iosif Murariu16-Jun-10 22:11
Iosif Murariu16-Jun-10 22:11 
GeneralRe: casting between pointers Pin
Code-o-mat16-Jun-10 22:52
Code-o-mat16-Jun-10 22:52 
AnswerRe: casting between pointers [modified] Pin
Aescleal16-Jun-10 22:29
Aescleal16-Jun-10 22:29 
GeneralRe: casting between pointers Pin
Iosif Murariu16-Jun-10 22:39
Iosif Murariu16-Jun-10 22:39 
GeneralRe: casting between pointers Pin
Aescleal16-Jun-10 22:58
Aescleal16-Jun-10 22:58 
AnswerRe: casting between pointers Pin
Tim Craig17-Jun-10 18:08
Tim Craig17-Jun-10 18:08 
QuestionDirect2D - printing / create windows meta file Pin
thomas1234516-Jun-10 21:26
thomas1234516-Jun-10 21:26 
AnswerRe: Direct2D - printing / create windows meta file Pin
salvapatuel230-Jun-10 6:41
salvapatuel230-Jun-10 6:41 
QuestionPDF Creation Pin
Pryabu16-Jun-10 20:35
Pryabu16-Jun-10 20:35 

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.