1

Actually i use a dll to export some methods to a unmanaged application.

I need to create a static var for the sf::Texture, but when i try, the dll is not correctly initialized.

I just add this line:

static Texture test3;

And the dll stop.

user3571412
  • 105
  • 1
  • 9
  • It is not clear what means that DLL stop. Do you get misterious crash? Do you fail linking? Do the compiler complain about annything? Do your application crash at a very precise point? (I think it crash when using the texture anyway) – CoffeDeveloper Jan 29 '17 at 17:53

1 Answers1

0

Regarding the effects of "static" as qualifier, those are covered in other answers. If you want to use "static" then you should know what "static" is doing.

In a C++ namespace does the `static` qualifier have any effect when prefixing non-member subroutines declared in the header?

I don't know what you are trying to achieve, but I think you may want to access that value through functions defined in your DLL.

In example

source.cpp

static Texture *myInternalTexture;

void InitInternalTexture(){
    myInternalTexture = new Texture( blah);
}

Texture *GetInternalTexture(){
    return myInternalTexture;
}

void ReleaseInternalTexture(){
    delete myInternalTexture;
}

Depending on your use you may prefer to access a reference of your texture or do a copy, I don't know what you need to do. In case you can easily adapt the code above to work with your Texture type.

Community
  • 1
  • 1
CoffeDeveloper
  • 7,961
  • 3
  • 35
  • 69