gcc -DENABLE_CODE_TEST -pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g3 -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE -O6 -fomit-frame-pointer -D__Darwin__ -DPOLLCOMPAT -c -o codetest.o codetest.c
codetest.c:35: warning: type defaults to 'int' in declaration of 'AST_LIST_HEAD_NOLOCK'
codetest.c:35: warning: parameter names (without types) in function declaration
codetest.c:35: warning: data definition has no type or storage class
codetest.c:39: error: field 'codetests' has incomplete type
codetest.c:40: error: parse error before 'AST_LIST_ENTRY'
codetest.c:40: warning: no semicolon at end of struct or union
codetest.c:43: error: parse error before 'testfile_list'
codetest.c:43: warning: type defaults to 'int' in declaration of 'testfile_list'
codetest.c:43: warning: data definition has no type or storage class
make: *** [codetest.o] Error 1
-----------------------------------------------
codetest.c
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1 $")
#include "asterisk/codetest.h"
AST_LIST_HEAD_NOLOCK(codetest_list, ast_codetest);
static struct testfile {
const char *name;
struct codetest_list codetests;
AST_LIST_ENTRY(file_link) list;
};
static AST_LIST_HEAD_STATIC(testfile_list, testfile) testfile_list;
int ast_register_codetest(const struct ast_codetest *test)
{
return 0;
}
int ast_unregister_codetest(const struct ast_codetest *test)
{
return 0;
}
------------------------------------------------
codetest.h
#ifndef __ASTERISK_CODETEST_H
#define __ASTERISK_CODETEST_H
#ifdef ENABLE_CODE_TEST
struct ast_codetest {
/*! The module that registered this test */
const char *module;
/*! The name of the test */
const char *testname;
/*! The codetest callback function */
int (*codetest)(int fd, int argc, char *argv[]);
};
#define AST_CODE_TEST(f) f
#define AST_DEFINE_CODE_TEST(name, tname, func) \
static const struct ast_codetest name = { __FILE__, tname, func }
int ast_register_codetest(const struct ast_codetest *test);
int ast_unregister_codetest(const struct ast_codetest *test);
#else
#define ast_register_codetest(f)
#define ast_unregister_codetest(f)
#define AST_CODE_TEST(f)
#define AST_DEFINE_CODE_TEST(name, testname, func)
#endif
#endif /* __ASTERISK_CODETEST_H */