Fixup header inclusion and C++ guards a bit

* Now headers only include headers they use (at least std headers).
* Remove CFU_DEBUG stuff since NDEBUG automatically controls assert()
* Make use of CFU_BEGIN_DECLS and CFU_END_DECLS macros from cfu.h.
This commit is contained in:
Matthew Brush 2013-03-04 03:17:00 -08:00
parent ec404e96a9
commit dd8b293d22
17 changed files with 26 additions and 147 deletions

View File

@ -1,12 +1 @@
SUBDIRS = src examples doc SUBDIRS = src examples doc
if DEBUG
AM_CFLAGS = -DCFU_VERSION="\"@VERSION@\"" -DCFU_DEBUG=1
else
AM_CFLAGS = -DCFU_VERSION="\"@VERSION@\""
endif
LIBCFU_TYPE_u_int=@LIBCFU_TYPE_u_int@
INCLUDES = -I$(top_srcdir)/include
EXTRA_DIST = include/cfutypes.h.in include/cfu.h.in

View File

@ -8,6 +8,7 @@ AM_INIT_AUTOMAKE([foreign -Wall silent-rules dist-bzip2])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_RANLIB AC_PROG_RANLIB
# Checks for header files. # Checks for header files.
@ -39,16 +40,6 @@ then
fi fi
AM_CONDITIONAL([USE_PTHREADS], [test x$have_pthreads = xyes]) AM_CONDITIONAL([USE_PTHREADS], [test x$have_pthreads = xyes])
# Allow enabling debug mode using configure argument
AC_ARG_ENABLE(debug,
[ --enable-debug Turn on debugging],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
src/Makefile src/Makefile

View File

@ -41,8 +41,6 @@
#ifndef _LIBCFU_H_ #ifndef _LIBCFU_H_
#define _LIBCFU_H_ #define _LIBCFU_H_
#include <stdio.h>
#ifdef __cplusplus #ifdef __cplusplus
#define CFU_BEGIN_DECLS extern "C" { #define CFU_BEGIN_DECLS extern "C" {
#define CFU_END_DECLS } #define CFU_END_DECLS }

View File

@ -46,16 +46,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef CFU_DEBUG
#ifdef NDEBUG
#undef NDEBUG
#endif
#else
#ifndef NDEBUG
#define NDEBUG 1
#endif
#endif
#include <assert.h> #include <assert.h>
struct cfuconf { struct cfuconf {

View File

@ -46,11 +46,7 @@
#include <cfulist.h> #include <cfulist.h>
#include <cfustring.h> #include <cfustring.h>
#include <stdio.h> CFU_BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
struct cfuconf; struct cfuconf;
typedef struct cfuconf cfuconf_t; typedef struct cfuconf cfuconf_t;
@ -119,8 +115,6 @@ extern "C" {
/* Print out a representation of the parsed configuration */ /* Print out a representation of the parsed configuration */
extern void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level); extern void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level);
#ifdef __cplusplus CFU_END_DECLS
}
#endif
#endif #endif

View File

@ -43,28 +43,18 @@
#endif #endif
#include "cfu.h" #include "cfu.h"
#include "cfuhash.h"
#include "cfustring.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h>
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
# include <pthread.h> # include <pthread.h>
#endif #endif
#include "cfuhash.h"
#include "cfustring.h"
#ifdef CFU_DEBUG
#ifdef NDEBUG
#undef NDEBUG
#endif
#else
#ifndef NDEBUG
#define NDEBUG 1
#endif
#endif
#include <assert.h>
typedef struct cfuhash_event_flags { typedef struct cfuhash_event_flags {
int resized:1; int resized:1;

View File

@ -42,13 +42,10 @@
#define _CFU_HASH_H_ #define _CFU_HASH_H_
#include <cfu.h> #include <cfu.h>
#include <sys/types.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h>
#ifdef __cplusplus CFU_BEGIN_DECLS
extern "C" {
#endif
/* The hash table itself. */ /* The hash table itself. */
struct cfuhash_table; struct cfuhash_table;
@ -270,8 +267,6 @@ extern "C" {
#define CFUHASH_IGNORE_CASE (1 << 5) /* treat keys case-insensitively */ #define CFUHASH_IGNORE_CASE (1 << 5) /* treat keys case-insensitively */
#ifdef __cplusplus CFU_END_DECLS
}
#endif
#endif #endif

View File

@ -45,6 +45,8 @@
#include "cfu.h" #include "cfu.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef HAVE_PTHREAD_H #ifdef HAVE_PTHREAD_H
# include <pthread.h> # include <pthread.h>
@ -53,17 +55,6 @@
#include "cfulist.h" #include "cfulist.h"
#include "cfustring.h" #include "cfustring.h"
#ifdef CFU_DEBUG
#ifdef NDEBUG
#undef NDEBUG
#endif
#else
#ifndef NDEBUG
#define NDEBUG 1
#endif
#endif
#include <assert.h>
typedef struct cfulist_entry { typedef struct cfulist_entry {
void *data; void *data;
size_t data_size; size_t data_size;

View File

@ -42,14 +42,9 @@
#define _CFU_LIST_ #define _CFU_LIST_
#include <cfu.h> #include <cfu.h>
#include <stddef.h>
#include <sys/types.h> CFU_BEGIN_DECLS
#include <stdio.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The list itself. */ /* The list itself. */
struct cfulist; struct cfulist;
@ -159,8 +154,6 @@ extern "C" {
extern char *cfulist_join(cfulist_t *list, const char *delimiter); extern char *cfulist_join(cfulist_t *list, const char *delimiter);
#ifdef __cplusplus CFU_END_DECLS
}
#endif
#endif #endif

View File

@ -10,16 +10,7 @@
#include "cfustring.h" #include "cfustring.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#ifdef CFU_DEBUG
#ifdef NDEBUG
#undef NDEBUG
#endif
#else
#ifndef NDEBUG
#define NDEBUG 1
#endif
#endif
#include <assert.h> #include <assert.h>
struct cfuopt_struct { struct cfuopt_struct {

View File

@ -3,7 +3,7 @@
* Change log: * Change log:
*/ */
#include "cfu.h" #include <cfu.h>
#ifndef _CFU_OPT_H_ #ifndef _CFU_OPT_H_
#define _CFU_OPT_H_ #define _CFU_OPT_H_

View File

@ -45,16 +45,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#ifdef CFU_DEBUG
#ifdef NDEBUG
#undef NDEBUG
#endif
#else
#ifndef NDEBUG
#define NDEBUG 1
#endif
#endif
#include <assert.h> #include <assert.h>
struct cfustring { struct cfustring {

View File

@ -42,13 +42,10 @@
#define _CFU_STRING_H_ #define _CFU_STRING_H_
#include <cfu.h> #include <cfu.h>
#include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h>
#ifdef __cplusplus CFU_BEGIN_DECLS
extern "C" {
#endif
struct cfustring; struct cfustring;
typedef struct cfustring cfustring_t; typedef struct cfustring cfustring_t;
@ -119,8 +116,6 @@ extern "C" {
/* Like cfustring_split_to_c_str(), but split a char * instead of a cfustring_t *. */ /* Like cfustring_split_to_c_str(), but split a char * instead of a cfustring_t *. */
extern char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...); extern char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...);
#ifdef __cplusplus CFU_END_DECLS
}
#endif
#endif #endif

View File

@ -11,16 +11,6 @@
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef CFU_DEBUG
#ifdef NDEBUG
#undef NDEBUG
#endif
#else
#ifndef NDEBUG
#define NDEBUG 1
#endif
#endif
#include <assert.h> #include <assert.h>
struct cfuthread_queue { struct cfuthread_queue {

View File

@ -44,9 +44,7 @@
#include <cfu.h> #include <cfu.h>
#ifdef __cplusplus CFU_BEGIN_DECLS
extern "C" {
#endif
/* cfuthread_queue provides a way to serialize requests for a /* cfuthread_queue provides a way to serialize requests for a
* resource where you want the resource to be accessed from a * resource where you want the resource to be accessed from a
@ -92,9 +90,6 @@ extern "C" {
*/ */
extern void cfuthread_queue_destroy(cfuthread_queue_t *); extern void cfuthread_queue_destroy(cfuthread_queue_t *);
#ifdef __cplusplus CFU_END_DECLS
}
#endif
#endif #endif

View File

@ -40,19 +40,11 @@
#include "cfu.h" #include "cfu.h"
#include "cfutime.h" #include "cfutime.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef CFU_DEBUG
#ifdef NDEBUG
#undef NDEBUG
#endif
#else
#ifndef NDEBUG
#define NDEBUG 1
#endif
#endif
#include <assert.h> #include <assert.h>
#include <sys/time.h>
typedef struct cfutime { typedef struct cfutime {
libcfu_type type; libcfu_type type;

View File

@ -43,11 +43,7 @@
#include <cfu.h> #include <cfu.h>
#include <sys/time.h> CFU_BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
struct cfutime; struct cfutime;
typedef struct cfutime cfutime_t; typedef struct cfutime cfutime_t;
@ -67,8 +63,6 @@ extern "C" {
/* Deallocate resources allocated for time. */ /* Deallocate resources allocated for time. */
extern void cfutime_free(cfutime_t *time); extern void cfutime_free(cfutime_t *time);
#ifdef __cplusplus CFU_END_DECLS
}
#endif
#endif #endif