Commit eb1a1a98 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(TYPE_CHECK_COMPILATION): New compilation switch.

(SUCCESS_AS_PTR): Ditto.
(Bool): Provide a pointer-based non-working implementation, that
	can be used for compile-time checks, but not for running code.
(Success): Provide a pointer-based implementation.  Switch to
	using it, at least for now; this might give us good warnings
	from the compilers.
parent 5127372a
/*
* $Id: misc-types.h,v 0.11 2003/08/16 11:29:08 ceder Exp $
* $Id: misc-types.h,v 0.12 2003/08/20 07:35:40 ceder Exp $
* Copyright (C) 1990-1991, 1994-1996, 1999 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -64,10 +64,57 @@
# undef TRUE
#endif
/* Define TYPE_CHECK_COMPILATION to get warnings from the compiler if
there is a mixup between Success and Bool. This doesn't produce
working code. In fact, it doesn't even compile. You will get
several errors, since a boolean expression cannot be assigned to a
pointer. You have to manually check that all reported errors are
due to the implementation below, and not because of a mixup. */
#undef TYPE_CHECK_COMPILATION
/* Define SUCCESS_AS_PTR if you want the Success type to be a pointer
rather than an enum. This should be a little less efficient, but
might get more errors from the compiler. Implied by
TYPE_CHECK_COMPILATION. */
#define SUCCESS_AS_PTR
#if defined(TYPE_CHECK_COMPILATION)
struct kom_bool {
short unused;
};
typedef const struct kom_bool *Bool;
extern const struct kom_bool *const TRUE;
extern const struct kom_bool *const FALSE;
#else
typedef enum { FALSE = 0, TRUE = 1 } Bool;
#endif
#if defined(SUCCESS_AS_PTR) || defined(TYPE_CHECK_COMPILATION)
struct success {
int unused[1];
};
typedef const struct success *Success;
extern const struct success *const OK;
extern const struct success *const FAILURE;
#else
typedef enum { OK = 017, FAILURE = 17 } Success;
#endif
#define NO_TIME ((time_t) 0)
#endif /* _MISC_TYPES_ALREADY_INCLUDED__ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment