Click here to Skip to main content
15,916,042 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Beep and MessageBeep Pin
Jochen Arndt5-Mar-14 21:15
professionalJochen Arndt5-Mar-14 21:15 
GeneralRe: Beep and MessageBeep Pin
_Flaviu5-Mar-14 21:22
_Flaviu5-Mar-14 21:22 
GeneralRe: Beep and MessageBeep Pin
Jochen Arndt5-Mar-14 21:42
professionalJochen Arndt5-Mar-14 21:42 
GeneralRe: Beep and MessageBeep Pin
cedricvictor5-Mar-14 21:52
cedricvictor5-Mar-14 21:52 
GeneralRe: Beep and MessageBeep Pin
Jochen Arndt5-Mar-14 22:46
professionalJochen Arndt5-Mar-14 22:46 
AnswerRe: Beep and MessageBeep Pin
«_Superman_»6-Mar-14 14:39
professional«_Superman_»6-Mar-14 14:39 
GeneralRe: Beep and MessageBeep Pin
cedricvictor6-Mar-14 19:10
cedricvictor6-Mar-14 19:10 
QuestionLinking global variables multiple times Pin
Vaclav_5-Mar-14 8:26
Vaclav_5-Mar-14 8:26 
I really need some advice with this „problem“.
I am rebuilding a class and according to the original its function is to act as „COM lookalike”Basically y a callback for DirectShow frame capture.
The original uses global variables and there is the “problem”.
No matter what I do the linker will complain about multiple definitions, but only on some variables.

I have made sure the variables are unique and compiled only once, same as the header file, but it does not help.

Here is the code:

#ifndef _CALLBACK_GLOBALS
#define _CALLBACK_GLOBALS
#pragma message( "Compiling " __FILE__ )
#pragma message( "Last modified on " __TIMESTAMP__ )

BOOL g_bOneShot_CB = FALSE;
DWORD g_dwGraphRegister_CB=0; // For running object table
HWND g_hwnd_CB;
// Structures
typedef struct _callbackinfo_CB
{
double dblSampleTime;
long lBufferSize;
BYTE *pBuffer;
BITMAPINFOHEADER bih;
}CALLBACKINFO_CB;
CALLBACKINFO_CB callback; // = {0};

#endif

And here is a small sample of linker errors:

_AVIFrame.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_AVIFrame.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_Blob.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_Blob.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_BlobTracker.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_BlobTracker.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_ChildFrame_Tab.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_ChildFrame_Tab.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_DocManager.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj
_DocManager.obj : error LNK2005: "struct _callbackinfo_CB callback" (?callback@@3U_callbackinfo_CB@@A) already defined in _Analysis_Contour.obj
_DrawBitmap.obj : error LNK2005: "int g_bOneShot_CB" (?g_bOneShot_CB@@3HA) already defined in _Analysis_Contour.obj


And here is sample usage
STDMETHODIMP BufferCB( double dblSampleTime, BYTE * pBuffer, long lBufferSize )
{
if( !g_bOneShot_CB )
return 0;
// Since we can't access Windows API functions in this callback, just
// copy the bitmap data to a global structure for later reference.
callback.dblSampleTime = dblSampleTime;
callback.lBufferSize = lBufferSize;

PS I did change the BOOL to bool and the linker error now reads “bool g_bOneShot_CB”...

Any hint how to fix this would be appreciated.

Cheers
Vaclav
SuggestionRe: Linking global variables multiple times Pin
David Crow5-Mar-14 9:36
David Crow5-Mar-14 9:36 
GeneralRe: Linking global variables multiple times SOLVED Pin
Vaclav_5-Mar-14 10:08
Vaclav_5-Mar-14 10:08 
QuestionCMapStringToString lookup() qestion [solved] Pin
econy5-Mar-14 4:56
econy5-Mar-14 4:56 
AnswerRe: CMapStringToString lookup() qestion Pin
Richard MacCutchan5-Mar-14 5:39
mveRichard MacCutchan5-Mar-14 5:39 
GeneralRe: CMapStringToString lookup() qestion Pin
econy5-Mar-14 9:12
econy5-Mar-14 9:12 
QuestionHeap ,Stack allocation question [Solved] Pin
econy5-Mar-14 3:57
econy5-Mar-14 3:57 
AnswerRe: Heap ,Stack allocation question Pin
Richard MacCutchan5-Mar-14 4:41
mveRichard MacCutchan5-Mar-14 4:41 
GeneralRe: Heap ,Stack allocation question Pin
econy5-Mar-14 4:47
econy5-Mar-14 4:47 
GeneralRe: Heap ,Stack allocation question Pin
Richard MacCutchan5-Mar-14 4:48
mveRichard MacCutchan5-Mar-14 4:48 
GeneralRe: Heap ,Stack allocation question Pin
econy5-Mar-14 5:04
econy5-Mar-14 5:04 
GeneralRe: Heap ,Stack allocation question Pin
Richard MacCutchan5-Mar-14 5:29
mveRichard MacCutchan5-Mar-14 5:29 
GeneralRe: Heap ,Stack allocation question Pin
econy5-Mar-14 9:06
econy5-Mar-14 9:06 
AnswerRe: Heap ,Stack allocation question Pin
Richard Andrew x645-Mar-14 10:10
professionalRichard Andrew x645-Mar-14 10:10 
GeneralRe: Heap ,Stack allocation question Pin
econy5-Mar-14 15:28
econy5-Mar-14 15:28 
GeneralRe: Heap ,Stack allocation question Pin
Richard MacCutchan5-Mar-14 22:24
mveRichard MacCutchan5-Mar-14 22:24 
Question#include cpp file - how it works? Pin
Vaclav_5-Mar-14 3:26
Vaclav_5-Mar-14 3:26 
AnswerRe: #include cpp file - how it works? Pin
Jochen Arndt5-Mar-14 4:12
professionalJochen Arndt5-Mar-14 4:12 

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.