0

I am currently using the following piece of code in my dll file:

typedef boost::function<void(int)> Function_Callback_type;

#pragma data_seg(".SHARED")
int common = 0 ;
Function_Callback_type  funct_callback;
#pragma data_seg()
#pragma comment(linker, "/section:.SHARED,RWS")

Now I want to assign a value to funct_callback. I read that if something is kept in the shared data segment of a dll file it needs to be initialized. My question is: How can I initialize the funct_callback to nothing ?

Columbo
  • 60,038
  • 8
  • 155
  • 203
MistyD
  • 16,373
  • 40
  • 138
  • 240

1 Answers1

1

My question is how can I initialize the funct_callback to nothing ?

If you mean "no function" or "no content": Don't do anything, the default-constructor is called automatically.

If you want to assign an empty function that does nothing, either use a lamda

Function_Callback_type  funct_callback = [] (int) {};

Or define an empty function yourself and assign that. (Or a functor class with an empty function call operator and assign a temporary of that class type)

Columbo
  • 60,038
  • 8
  • 155
  • 203