Library extention code style

hi all; I’m in the process of contributing a few library’s for SDL and was wondering if there is a preferred coding style used, from what I’ve seen many if not all of the extension libs match SDL coding style.

Code:
SDL_Struct *
SDL_Function()

Is this the preferred style to use? do we have a style guide to read or am I just being a little anal here lol

houston.

There really isn’t a style guide - as long as you have consistent code, and
moderately good documentation, things will be fine. If you are contributing
to SDL itself, I think SDL_struct / SDL_func are preferred.

I hope that helps,
-AlexOn Wed, Nov 24, 2010 at 5:30 PM, SDL_sui <housty.g at gmail.com> wrote:

hi all; I’m in the process of contributing a few library’s for SDL and
was wondering if there is a preferred coding style used, from what I’ve seen
many if not all of the extension libs match SDL coding style.

Code:

SDL_Struct *
SDL_Function()

Is this the preferred style to use? do we have a style guide to read or am
I just being a little anal here lol

houston.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Code style is about more than just the naming of the identifiers, although
that is a large part.

SDL has a consistent error checking mechanism too. Functions that return
pointers will return NULL on error, other functions return a negative
integer on error, and 0 on success. The error message is handled by
SDL_GetError(). This often means writing the function to accept pointers to
"out" parameters rather than simply returning a value - see the SDL API for
details. In particular, almost all functions should be able to return an
error - this is vital in the case where your code is extended later and
might need to do something, like an allocation, that could fail.

SDL uses SDL-provided explicitly sized integers for its structures.

SDL’s headers are conditionally wrapped with ‘extern “C”’ to interoperate
well with C++ code.

This is ignoring the internal conventions, such as how to format functions
and different kinds of statements. For a SDL add-on library following the
external conventions is more important than the latter.

I’m sure there is more but that is what I can think of at the moment. If you
take some time to go through some of the SDL headers you might see more
conventions. Good luck with the add on library!

– BrianOn 24 November 2010 22:30, SDL_sui <housty.g at gmail.com> wrote:

hi all; I’m in the process of contributing a few library’s for SDL and
was wondering if there is a preferred coding style used, from what I’ve seen
many if not all of the extension libs match SDL coding style.