I'm making a program with a global vector filled with objects and putting it in a namespace here's the code:
Character.h:
#include <vector>
class Character
{
  //Constructor and variable declaration, etc.
}
class Player: public Character
{
  //Constructor and variable declaration, etc.
}
namespace chr
{
 extern std::vector<Character> characters;
 extern Player player_one;
}
Character.cpp:
namespace chr
{
 Player player_one("name");
 std::vector <Character> characters;
}
main:
#include <SFML/Graphics.hpp> //I'm using the SFML libraries
#include "Personaje.h"
 int main()
 {
 Player player_two("name"); //just to test that single object work (they do)
 chr::personajes.push_back(chr::player_one); //HERE'S THE ISSUE
 
  //sample SFML code to check if the rest of the program works
 sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
 sf::CircleShape shape(100.f);
 shape.setFillColor(sf::Color::Green);
 while (window.isOpen())
 {
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            window.close();
    }
    window.clear();
    window.draw(shape);
    window.display();
 }
return 0;
}
When I build this code (I'm using code::Blocks) it actually compiles without errors, but when I run it, as soon as the console comes up (the SFML window doesn't even pop up) it freezes and a Windows notification appears informing me that my program has stopped working. I know it's the code on the chr namespace that is causing this because if I comment it out the program runs fine, but I don't know why this is. If it's of any help, when the program crashes Windows opens the Visual Studio debugger, which produces this message:
Exception thrown at 0x0044EFA2 in wtfhappened.exe: 0xC0000005: Access violation reading location 0xFFFFFFFC.
If there is a handler for this exception, the program may be safely continued.
Thanks for your time
 
     
    