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

C / C++ / MFC

 
AnswerRe: x ==> next biggest power of two Pin
David Crow17-Mar-06 16:42
David Crow17-Mar-06 16:42 
AnswerRe: x ==> next biggest power of two Pin
cmk18-Mar-06 12:44
cmk18-Mar-06 12:44 
QuestionHow can I have a window with thick frame but no resize? Pin
Axonn Echysttas17-Mar-06 4:54
Axonn Echysttas17-Mar-06 4:54 
AnswerRe: How can I have a window with thick frame but no resize? Pin
basementman17-Mar-06 5:38
basementman17-Mar-06 5:38 
GeneralRe: How can I have a window with thick frame but no resize? Pin
Axonn Echysttas17-Mar-06 5:45
Axonn Echysttas17-Mar-06 5:45 
GeneralRe: How can I have a window with thick frame but no resize? Pin
PJ Arends17-Mar-06 6:00
professionalPJ Arends17-Mar-06 6:00 
AnswerRe: How can I have a window with thick frame but no resize? Pin
PJ Arends17-Mar-06 5:41
professionalPJ Arends17-Mar-06 5:41 
QuestionProblem with member static data initialization in win32 DLL Pin
Divick17-Mar-06 4:40
Divick17-Mar-06 4:40 
Hi,
I have a DLL which has a class containing static members. In the
implementation file of the class I have done proper initialization of
the static data. These static data are public thus I want to modify
these public static data from another application using this DLL.

Somehow the static initialization is not happening if it is done in the
implementation file and while accessing the storage for static data my
VC7 compiler complains that I am trying to write to an illegal memory.
But if I do the static initialization in the header file itself then I
get no run time error. As far as I know static data initialization
should not be done in header file. So really my question is why is this
happening in the first place and what I need to do to fix it?

DLL CODE:
///////////////////////////////Header
file//////////////////////////////////////////
typedef void (*fptr)(void);

class DllMethods
{
public:
__declspec(dllexport) static int data;
__declspec(dllexport) static fptr function;
};

/////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////Implementation
file//////////////////////////////
#include "DllMethods.h"

//IF THIS INITIALIZATION IS DONE IN THE HEADER FILE FOR THE DLL
//THEN I GET NO ERROR WHEN DEBUGGING WITH VC7 COMPILER
fptr DllMethods::function = 0;
int DllMethods::data = 46;
///////////////////////////////////////////////////////////////////////////////////////

APPLICATION CODE:
#include "DllMethods.h"

#include <iostream>
using namespace std;

static void anotherFunction(void)
{
cout << "Inside anotherFunction" << endl;

}

int main(int argc, char ** argv)
{
//I GET RUNTIME ERROR WHEN THE FOLLOWING LINE
//EXECUTES AND WHEN THE STATIC INITIALIZATION IS
//DONE IN THE IMPLEMENTATION FILE
//BUT IF THE INITIALIZATION IS DONE IN THE HEADER ITSELF
//THEN I GET NO ERROR

//ASSIGN THE FUNCTION PTR OF THE DLL TO THE FUNCTION
//IN THE APPLICAITON
DllMethods::function = anotherFunction;

DllMethods::function();

return 0;
}

Thanks,

Divick
QuestionCFile::Remove; Use with network file Pin
Chris Meech17-Mar-06 4:21
Chris Meech17-Mar-06 4:21 
AnswerRe: Removes Egg from face Pin
Chris Meech17-Mar-06 4:41
Chris Meech17-Mar-06 4:41 
QuestionIntel based Macintosh - Windows General Question (??) Pin
Lampros Giampouras17-Mar-06 3:34
Lampros Giampouras17-Mar-06 3:34 
AnswerRe: Intel based Macintosh - Windows General Question (??) Pin
Chris Losinger17-Mar-06 3:41
professionalChris Losinger17-Mar-06 3:41 
AnswerRe: Intel based Macintosh - Windows General Question (??) Pin
Maximilien17-Mar-06 4:12
Maximilien17-Mar-06 4:12 
AnswerRe: Intel based Macintosh - Windows General Question (??) Pin
jhwurmbach17-Mar-06 5:03
jhwurmbach17-Mar-06 5:03 
GeneralRe: Intel based Macintosh - Windows General Question (??) Pin
Lampros Giampouras17-Mar-06 6:38
Lampros Giampouras17-Mar-06 6:38 
GeneralRe: Intel based Macintosh - Windows General Question (??) Pin
jhwurmbach17-Mar-06 6:47
jhwurmbach17-Mar-06 6:47 
QuestionHow to Create Chevron Button Pin
BlueCrack17-Mar-06 3:10
BlueCrack17-Mar-06 3:10 
QuestionRe: How to Create Chevron Button Pin
toxcct17-Mar-06 3:36
toxcct17-Mar-06 3:36 
AnswerRe: How to Create Chevron Button Pin
BlueCrack17-Mar-06 3:38
BlueCrack17-Mar-06 3:38 
GeneralRe: How to Create Chevron Button Pin
toxcct17-Mar-06 3:39
toxcct17-Mar-06 3:39 
GeneralRe: How to Create Chevron Button Pin
BlueCrack17-Mar-06 3:41
BlueCrack17-Mar-06 3:41 
GeneralRe: How to Create Chevron Button Pin
toxcct17-Mar-06 3:45
toxcct17-Mar-06 3:45 
GeneralRe: How to Create Chevron Button Pin
BlueCrack17-Mar-06 3:48
BlueCrack17-Mar-06 3:48 
GeneralRe: How to Create Chevron Button Pin
QuiJohn17-Mar-06 6:38
QuiJohn17-Mar-06 6:38 
AnswerRe: How to Create Chevron Button Pin
Nibu babu thomas19-Mar-06 17:31
Nibu babu thomas19-Mar-06 17:31 

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.