1
General / Re: Static linking problem with VS2019
« on: August 29, 2019, 05:25:34 pm »
I agree that there's no prebuilt binaries for VS2019 but it doesn't really matter for dynamic linking then?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
And... really, doing all this stuff at global initialization (before entering main), is not only UB (because some global SFML objects may not be created yet), but also not really a great idea for handling errors, logging, etc.Tbh I don't use global values. I use class with const private fields.
This leads to discussions about error handling, exceptions, etc. but this is a complex topicThat's good but let me ask then - why it cannot be smth like
Thread-safety is never achieved with const. You need synchronization primitives in any case.I didn't really mean this. I mean that I would like to copy static const texture to each sf::Sprite in my std::list<>, for example. This can be done parallel, right? But I'm not sure it will happen if it stays mutable. Nevermind
I actually did think about several of these initializing functions that would provide me all constants I need. Even if I can make them inline, don't you think it looks sort of workaround?sf::Texture makeTexture(const std::string& filename)
{
sf::Texture t;
t.loadFromFile(filename); // put some log on failure at least, but beware of global objects initialization order
return t;
}
const sf::Texture MyClass::texture = makeTexture("...");