[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lily/freetype-error.cc: const struct #include ;
From: |
Werner LEMBERG |
Subject: |
Re: lily/freetype-error.cc: const struct #include ; |
Date: |
Tue, 07 Sep 2010 00:12:58 +0200 (CEST) |
>> As a C programmer, it took me about 30 seconds (or less) to twig what it
>> was doing.
>
> Could you take 120 seconds or so to explain what it's doing? I'm
> supposed to be teaching first-year C programming, and I haven't run
> across this before.
Here is the documentation from fterrors.h:
/*************************************************************************/
/* */
/* This special header file is used to define the handling of FT2 */
/* enumeration constants. It can also be used to generate error message */
/* strings with a small macro trick explained below. [...] */
/* */
/* II - Error Message strings */
/* -------------------------- */
/* */
/* The error definitions below are made through special macros that */
/* allow client applications to build a table of error message strings */
/* if they need it. The strings are not included in a normal build of */
/* FreeType 2 to save space (most client applications do not use */
/* them). */
/* */
/* To do so, you have to define the following macros before including */
/* this file: */
/* */
/* FT_ERROR_START_LIST :: */
/* This macro is called before anything else to define the start of */
/* the error list. It is followed by several FT_ERROR_DEF calls */
/* (see below). */
/* */
/* FT_ERROR_DEF( e, v, s ) :: */
/* This macro is called to define one single error. */
/* `e' is the error code identifier (e.g. FT_Err_Invalid_Argument). */
/* `v' is the error numerical value. */
/* `s' is the corresponding error string. */
/* */
/* FT_ERROR_END_LIST :: */
/* This macro ends the list. */
/* */
/* Additionally, you have to undefine __FTERRORS_H__ before #including */
/* this file. */
/* */
/* Here is a simple example: */
/* */
/* { */
/* #undef __FTERRORS_H__ */
/* #define FT_ERRORDEF( e, v, s ) { e, s }, */
/* #define FT_ERROR_START_LIST { */
/* #define FT_ERROR_END_LIST { 0, 0 } }; */
/* */
/* const struct */
/* { */
/* int err_code; */
/* const char* err_msg; */
/* } ft_errors[] = */
/* */
/* #include FT_ERRORS_H */
/* } */
/* */
/*************************************************************************/
fterrors.h defines fallbacks for those macros, and lilypond simply
uses them.
> But why does the #include need to be in the middle of the = and ; ?
I hope that the explanation above gives you the idea.
Werner
- lily/freetype-error.cc: const struct #include ;, Graham Percival, 2010/09/06
- Re: lily/freetype-error.cc: const struct #include ;, Carl Sorensen, 2010/09/06
- Re: lily/freetype-error.cc: const struct #include ;, Werner LEMBERG, 2010/09/06
- Re: lily/freetype-error.cc: const struct #include ;, Wols Lists, 2010/09/06
- Re: lily/freetype-error.cc: const struct #include ;, Alexander Kobel, 2010/09/06
- Re: lily/freetype-error.cc: const struct #include ;, Alexander Kobel, 2010/09/06
- Re: lily/freetype-error.cc: const struct #include ;, Graham Percival, 2010/09/10