Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Exception Thrown at line where I defined sf::Texture  (Read 3102 times)

0 Members and 1 Guest are viewing this topic.

sadin97

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Exception Thrown at line where I defined sf::Texture
« on: September 14, 2017, 10:34:28 pm »
Code: [Select]
Exception thrown at 0x7749B2E3 (ntdll.dll) in App.exe: 0xC0000005: Access violation writing location 0x00000004.

At line:

Code: [Select]
sf::Texture seaTexture;
In file resources.cpp

I also put:

Code: [Select]
extern sf::Texture seaTexture;
in file resources.h

So... can I do something like this. Im using seaTexture in another file so I tried to put extern to it.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10910
    • View Profile
    • development blog
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #1 on: September 15, 2017, 12:20:23 am »
You're probably using the wrong DLLs, e.g. outdated DLLs, x64 vs x86 mismatch or DLLs with different runtime libraries. Make sure everything is matching and that you don't have old libraries and keep in mind that VS comes with two kinds of compilers, one for x86 and one for x64, you have to pick the right one.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sadin97

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #2 on: September 15, 2017, 12:48:27 am »
You're probably using the wrong DLLs, e.g. outdated DLLs, x64 vs x86 mismatch or DLLs with different runtime libraries. Make sure everything is matching and that you don't have old libraries and keep in mind that VS comes with two kinds of compilers, one for x86 and one for x64, you have to pick the right one.

Are you sure that is the problem? I can use generally sf::Texture... but with this making it extern I got problems.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #3 on: September 15, 2017, 06:27:55 am »
Some SFML resources can't be declared in the global scope. They do internal stuff during their construction and destruction, which involves other global variables that may not be available due to non-deterministic order of initialization of globals.
Laurent Gomila - SFML developer

sadin97

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #4 on: September 16, 2017, 10:33:08 pm »
Some SFML resources can't be declared in the global scope. They do internal stuff during their construction and destruction, which involves other global variables that may not be available due to non-deterministic order of initialization of globals.

So... any hint? How should I use same texture in other file if it is even possible?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10910
    • View Profile
    • development blog
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #5 on: September 16, 2017, 11:59:16 pm »
Pass by reference.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sadin97

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #6 on: September 17, 2017, 06:48:49 pm »
Pass by reference.

Can you post some simple examples using textures?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10910
    • View Profile
    • development blog
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #7 on: September 17, 2017, 08:30:09 pm »
A reference works the same way for any type. If you don't know how a reference works, you should go back to pure C++ for a bit and read it up in a good C++ book. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sadin97

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Exception Thrown at line where I defined sf::Texture
« Reply #8 on: September 17, 2017, 09:44:00 pm »
A reference works the same way for any type. If you don't know how a reference works, you should go back to pure C++ for a bit and read it up in a good C++ book. ;)

Okay, thanks for help! :)

 

anything