1 /***************************************************************************/
5 /* FreeType error code handling (specification). */
7 /* Copyright 1996-2002, 2004, 2007, 2013 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
19 /*************************************************************************/
21 /* This special header file is used to define the handling of FT2 */
22 /* enumeration constants. It can also be used to generate error message */
23 /* strings with a small macro trick explained below. */
25 /* I - Error Formats */
26 /* ----------------- */
28 /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */
29 /* defined in ftoption.h in order to make the higher byte indicate */
30 /* the module where the error has happened (this is not compatible */
31 /* with standard builds of FreeType 2). See the file `ftmoderr.h' for */
35 /* II - Error Message strings */
36 /* -------------------------- */
38 /* The error definitions below are made through special macros that */
39 /* allow client applications to build a table of error message strings */
40 /* if they need it. The strings are not included in a normal build of */
41 /* FreeType 2 to save space (most client applications do not use */
44 /* To do so, you have to define the following macros before including */
47 /* FT_ERROR_START_LIST :: */
48 /* This macro is called before anything else to define the start of */
49 /* the error list. It is followed by several FT_ERROR_DEF calls */
52 /* FT_ERROR_DEF( e, v, s ) :: */
53 /* This macro is called to define one single error. */
54 /* `e' is the error code identifier (e.g. FT_Err_Invalid_Argument). */
55 /* `v' is the error numerical value. */
56 /* `s' is the corresponding error string. */
58 /* FT_ERROR_END_LIST :: */
59 /* This macro ends the list. */
61 /* Additionally, you have to undefine __FTERRORS_H__ before #including */
64 /* Here is a simple example: */
67 /* #undef __FTERRORS_H__ */
68 /* #define FT_ERRORDEF( e, v, s ) { e, s }, */
69 /* #define FT_ERROR_START_LIST { */
70 /* #define FT_ERROR_END_LIST { 0, 0 } }; */
75 /* const char* err_msg; */
78 /* #include FT_ERRORS_H */
81 /*************************************************************************/
84 #ifndef __FTERRORS_H__
85 #define __FTERRORS_H__
88 /* include module base error codes */
89 #include FT_MODULE_ERRORS_H
92 /*******************************************************************/
93 /*******************************************************************/
95 /***** SETUP MACROS *****/
97 /*******************************************************************/
98 /*******************************************************************/
101 #undef FT_NEED_EXTERN_C
104 /* FT_ERR_PREFIX is used as a prefix for error identifiers. */
105 /* By default, we use `FT_Err_'. */
107 #ifndef FT_ERR_PREFIX
108 #define FT_ERR_PREFIX FT_Err_
112 /* FT_ERR_BASE is used as the base for module-specific errors. */
114 #ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
117 #define FT_ERR_BASE FT_Mod_Err_Base
123 #define FT_ERR_BASE 0
125 #endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
128 /* If FT_ERRORDEF is not defined, we need to define a simple */
129 /* enumeration type. */
133 #define FT_ERRORDEF( e, v, s ) e = v,
134 #define FT_ERROR_START_LIST enum {
135 #define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
138 #define FT_NEED_EXTERN_C
142 #endif /* !FT_ERRORDEF */
145 /* this macro is used to define an error */
146 #define FT_ERRORDEF_( e, v, s ) \
147 FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
149 /* this is only used for <module>_Err_Ok, which must be 0! */
150 #define FT_NOERRORDEF_( e, v, s ) \
151 FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
154 #ifdef FT_ERROR_START_LIST
159 /* now include the error codes */
160 #include FT_ERROR_DEFINITIONS_H
163 #ifdef FT_ERROR_END_LIST
168 /*******************************************************************/
169 /*******************************************************************/
171 /***** SIMPLE CLEANUP *****/
173 /*******************************************************************/
174 /*******************************************************************/
176 #ifdef FT_NEED_EXTERN_C
180 #undef FT_ERROR_START_LIST
181 #undef FT_ERROR_END_LIST
185 #undef FT_NOERRORDEF_
187 #undef FT_NEED_EXTERN_C
190 /* FT_ERR_PREFIX is needed internally */
191 #ifndef FT2_BUILD_LIBRARY
195 #endif /* __FTERRORS_H__ */