Freetype bonehead code

Discuss Programming
Post Reply
worker201
guru
guru
Posts: 668
Joined: Sun Jun 13, 2004 6:38 pm
Location: Hawaii

Freetype bonehead code

Post by worker201 » Sun May 22, 2005 4:55 am

For some reason, I was messing around in freetype.h this evening, and I saw the strangest thing.

The first set of instructions is:

Code: Select all

#ifndef FT_FREETYPE_H
#error "`ft2build.h' hasn't been included yet!"
#error "Please always use macros to include FreeType header files."
#error "Example:"
#error "  #include <ft2build.h>"
#error " #include FT_FREETYPE_H"
#endif


#ifndef __FREETYPE_H__
#define __FREETYPE_H__
Which is easy enough to understand - ft2build.h defines FT_FREETYPE_H, and if it isn't defined, then ft2build.h hasn't been loaded yet. Since it's kinda important, you should load it. So far so good.

Then, the next section of code:

Code: Select all

#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 1
#define FREETYPE_PATCH 9


#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_ERRORS_H
#include FT_TYPES_H
actually contains an include for ft2build.h, just in case. Too bad that by this point, whatever was reading this has already quit! In order to build Xft from source, which has a freetype.h dependency, I had to comment out the first section. After that, everything was great.

It seems like a really strange thing to do. If the variable is undefined, you should just go ahead and define it:

Code: Select all

#ifndef FT_FREETYPE_H
#include <ft2build.h>
#define FT__FREETYPE_H
#endif
Unless I don't know my defs/includes very well (a quite likely possibility!), then I must declare this is a somewhat broken header. Does anyone care to comment on this?

Post Reply