Click here to Skip to main content
15,918,976 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error regarding .sbr file in VC++ 2005 Pin
Paresh Chitte5-Aug-07 20:02
Paresh Chitte5-Aug-07 20:02 
AnswerRe: Error regarding .sbr file in VC++ 2005 Pin
Shouvik Das5-Aug-07 19:48
Shouvik Das5-Aug-07 19:48 
GeneralRe: Error regarding .sbr file in VC++ 2005 Pin
yudhisthira5-Aug-07 19:55
yudhisthira5-Aug-07 19:55 
AnswerRe: Error regarding .sbr file in VC++ 2005 Pin
ThatsAlok5-Aug-07 19:53
ThatsAlok5-Aug-07 19:53 
GeneralRe: Error regarding .sbr file in VC++ 2005 Pin
yudhisthira5-Aug-07 19:56
yudhisthira5-Aug-07 19:56 
GeneralRe: Error regarding .sbr file in VC++ 2005 Pin
ThatsAlok5-Aug-07 20:20
ThatsAlok5-Aug-07 20:20 
Questionstatic member variable, dll export and multiple translation units Pin
devvvy5-Aug-07 15:43
devvvy5-Aug-07 15:43 
AnswerRe: static member variable, dll export and multiple translation units [modified*2] Pin
Mark Salsbery5-Aug-07 16:41
Mark Salsbery5-Aug-07 16:41 
You can do something like this:
<font size="3">// From DLL A - header:</font>

<font color="Red">#ifdef _BUILDINGDLL
   #define _MY_IMPORTEXPORT __declspec(dllexport);
#else
   #define _MY_IMPORTEXPORT __declspec(dllimport);
#endif</font>

class <font color="Red">_MY_IMPORTEXPORT</font> CLogEntry
{
public:
   ...

   static CLog* GetSingletonLoggingProvider() { return s_pSingletonLoggingProvider; }
   ...

protected:
   ...
   static CLog * s_pSingletonLoggingProvider;
};


<font size="3">// .cpp file:</font>

#include "stdafx.h"

#include "LogEntry.h"

CLog * CLogEntry::s_pSingletonLoggingProvider = NULL; 

CLogEntry::CLogEntry(int nId, nsCLog::eSeverity nSeverity, char* lpszCode, char* lpszMsg, DWORD dwWin32ErrorCode, CLogEntry * pParent)
{
   ...
}
... the rest of it...
Define _BUILDINGDLL (in the compiler preprocessor settings) when building DLL A.
Don't define it when building DLL B

Do NOT redefine  s_pSingletonLoggingProvider in DLL B. 

Instead use like any other static members (they are imported for external builds, exported when building DLL A):

CLog *pLog = CLogEntry::GetSingletonLoggingProvider();


Make sense?

Mark


Last modified: 2hrs 51mins after originally posted --


Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: static member variable, dll export and multiple translation units Pin
devvvy5-Aug-07 18:42
devvvy5-Aug-07 18:42 
GeneralRe: static member variable, dll export and multiple translation units Pin
Mark Salsbery5-Aug-07 19:23
Mark Salsbery5-Aug-07 19:23 
GeneralRe: static member variable, dll export and multiple translation units [modified*2] Pin
devvvy5-Aug-07 22:17
devvvy5-Aug-07 22:17 
GeneralRe: static member variable, dll export and multiple translation units Pin
Mark Salsbery6-Aug-07 4:59
Mark Salsbery6-Aug-07 4:59 
GeneralRe: static member variable, dll export and multiple translation units [modified*2] Pin
devvvy5-Aug-07 22:24
devvvy5-Aug-07 22:24 
GeneralRe: static member variable, dll export and multiple translation units Pin
Mark Salsbery6-Aug-07 5:01
Mark Salsbery6-Aug-07 5:01 
GeneralRe: static member variable, dll export and multiple translation units Pin
devvvy6-Aug-07 13:57
devvvy6-Aug-07 13:57 
GeneralRe: static member variable, dll export and multiple translation units Pin
Mark Salsbery6-Aug-07 14:22
Mark Salsbery6-Aug-07 14:22 
Question2 dim numbers.. Pin
_80865-Aug-07 7:54
_80865-Aug-07 7:54 
AnswerRe: 2 dim numbers.. Pin
Maxwell Chen13-Aug-07 0:56
Maxwell Chen13-Aug-07 0:56 
Questionabout static libraries Pin
mt_samiei5-Aug-07 4:01
mt_samiei5-Aug-07 4:01 
QuestionRe: about static libraries Pin
Mark Salsbery5-Aug-07 7:40
Mark Salsbery5-Aug-07 7:40 
QuestionHighlight text in static control Pin
Legolas655-Aug-07 1:55
Legolas655-Aug-07 1:55 
AnswerRe: Highlight text in static control Pin
Hamid_RT5-Aug-07 3:49
Hamid_RT5-Aug-07 3:49 
GeneralRe: Highlight text in static control Pin
Legolas655-Aug-07 6:31
Legolas655-Aug-07 6:31 
GeneralRe: Highlight text in static control Pin
Hamid_RT5-Aug-07 19:02
Hamid_RT5-Aug-07 19:02 
AnswerRe: Highlight text in static control Pin
henky@online-resource.org5-Aug-07 23:10
henky@online-resource.org5-Aug-07 23:10 

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.