So, I’m learning SDL using C.
After mucking around a bit, I managed to get SDL_Init() to give a segmentation fault. After some investigation, it turns out the culprit was that I created a function int connect(). If I rename the function to something else e.g. my_connect(), then everything works fine.
I figured that a function named connect() already exists somewhere in the SDL library and my definition is causing a clash. However, the API doesn’t have any mention of a function named connect or anything like it.
Are there other names I should avoid when using SDL? Where can I find a list of them?
… or is this just another fine example of the need for encapsulation?
All SDL names start with SDL_. However, SDL can call standard C functions, such as connect, to function. If your application creates a global function with that name, it replaces the one from the standard library, thus making SDL use yours instead of the global one. Using a different name solves the problem, indeed. Another option would be to make your function static (but then you must not need it globally, of course).