This entry was posted on Wednesday, February 8th, 2012 at 3:58 pm and is filed under Tech Stuff. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
If you are trying to use a cheeky file static or global variable while eagerly developing your C++/CLI software you will probably encounter the following error:
“C3145, global or static variable may not have managed type”
At this point you remember that this isn’t really C++ but a crazy non-standard extension to C++! So instead of declaring a file static scope variable like this:
|
1 |
static Acquisition::IImage^ simage = nullptr; |
So as a fix, you can declare a container class and add it as a static member, thus:
|
1 2 3 4 |
ref class ImageContainer { public: static Acquisition::IImage^ Image = nullptr; }; |
And then access it in this way:
|
1 |
ImageContainer::Image = image; |
Thus solution worked well for us, but of course we will be getting rid of this global variable in due time!
