tl;dr: Just use references.
You can completely avoid your problem, and get the convenient calling convention you like - without instantiating any unnecessary copies of structs - if your wrappers use references. If you're new to C++, you can read this StackOverflow question, which introduces them briefly: References in C++.
At any rate, if the SDL function you want to wrap has the signature:
void SDL_foo(SDL_Rect *rect);
then your wrapper would be:
inline void my_wrapper_name(SDL_Rect& rect) {
SDL_foo(&rect);
}
and that works even if SDL_Rect
has only been forward-declared!
Now, if you're sure that the SDL_Rect
will:
- Never be used except in the call to
SDL_foo()
and
- Not be modified by
SDL_foo()
despite it not being designated as taking a const SDL_Rect*
you can also write:
inline void my_wrapper_name(const SDL_Rect& rect) {
SDL_foo(const_cast<SDL_Rect*>(&rect));
}
in which case you would be able, elswhere in your code and with SDL_Rect
actually defined, to invoke your wrapper on an initializer list for an SDL_Rect
.