We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3796 - Documentation request: functions can be called without SDL_Init(), especially SDL_GetBasePath() and SDL_GetPrefPath()
Summary: Documentation request: functions can be called without SDL_Init(), especially...
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: file (show other bugs)
Version: 2.0.5
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-04 19:04 UTC by LGB
Modified: 2017-09-05 16:48 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LGB 2017-09-04 19:04:45 UTC
I have an application where SDL initialization depends on configuration settings stored in configuration files. Since the configuration file is in directory given by SDL_GetBasePath() or SDL_GetPrefPath() (choice of the user), it's somewhat chicken and egg problem, if these requires SDL_Init() first. What I am not sure about.

I would like to ask some documentation clarify, that these functions can be used anywhere (even before SDL_Init) or not. Great example is SDL_ShowSimpleMessageBox() where it's stated that it can be used everywhere. My point here, that maybe it should be marked everywhere if this is the case with a given function (again: I am not sure if this is the case with those I want to use that way). So my request can be interpreted in general too (and maybe it's my fault that I assume it's not already that, and I should not do what I want, btw).

I'm really not sure if it's OK to ask here as a report here, sorry if it's not the proper method. Thanks for your time!
Comment 1 Sylvain 2017-09-05 11:06:49 UTC
It may work for one platform and not the other...

maybe you could do :

SDL_Init() with no sub-system
GetPrefPath()
SDL_Quit()
Comment 2 LGB 2017-09-05 15:50:37 UTC
Thanks for the tip. Can I assume, that with SDL_Init(0) before my getpath stuff, and SDL_Quit() after it makes a situation as it wouldn't been any SDL call yet? Since it can also happen that I don't want to initialize SDL (based on the the content of the configuration file, whose path is known with SDL_GetPrefPat) at all, and I wouldn't like to interference with anything. Also, if it turns out I need SDL, I assume, I can use SDL_Init() later again (of course not with argument of zero then!). I've checked this and seems to work (on Linux), but I would like to be sure, if this behaviour is correct expectation, works on all platforms, and will be in the future too.

But anyway, thanks for your comment, so there is no point for my ticket here to update the documentation, since it's really not safe to use these functions without SDL_Init(), and for being safe, I need something like the trick you've mentioned.
Comment 3 Sam Lantinga 2017-09-05 16:48:45 UTC
Yep, that should be safe. If it's not, that would be a bug, and you can report it here.