wiki:CodingStyle

Project's coding style

The coding style is described in the manual at http://roaraudio.keep-cool.org/lo/roarmanual.pdf

Examples

Those examples should give yous some overview. They are not complete. See the manual for more details.

//right.c:

/*
 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011
 *
 *  This file is part of roard a part of RoarAudio,
 *  a cross-platform sound system for both, home and professional use.
 *  See README for details.
 *
 *  This file is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3
 *  as published by the Free Software Foundation.
 *
 *  RoarAudio is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this software; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 *
 */

#include "roard.h"

int function_without_args(void) {
 const char * data[] = {"some", "test", "data"};
 int ret;
 int i;

 for (i = 0; i < (sizeof(data)/sizeof(*data)); i++)
  put_data(data[i]);

 ret = get_ret();
 set_ret(ret);

 return 0;
}

int setup(struct type_t * out, int arg0, int arg1) {
 memset(out, 0, sizeof(*out));

 if ( out == NULL ) {
  roar_err_set(ROAR_ERROR_FAULT);
  return -1;
 }

 out->para_base     = arg0;
 out->para_exponent = arg1;

 if ( arg0 ) {
  out->non_zero = 1;
 } else {
  out->non_zero = 0;
 }

 if ( check_value(out) == -1 )
  return -1;

 return 0;
}

//ll

Wrong

#include "roard.h"
int function_without_args ()
{
        const char * data[] = {"some", "test", "data"};
        for (int i = 0; i < 3; i++)
                put_data (data[i]);
        int ret = get_ret();
        set_ret (ret);
        return 0;
}

int setup (int arg0, int arg1, struct type_t * out)
{
        if (!out) {
                return -ROAR_ERROR_FAULT;
        }

        out->para_base=arg0;
        out->para_exponent=arg1;

        if ( arg0 )
                out->non_zero = 1;
        else
                out->non_zero = 0;

        return -check_value(out);
}
Last modified 10 years ago Last modified on 07/25/11 14:04:10