freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Solved: FT2 "interface" keyword problem with MS Visual C


From: Jack Davis
Subject: Solved: FT2 "interface" keyword problem with MS Visual C
Date: Thu, 17 Feb 2000 15:30:07 -0800

Microsoft's windows.h (or one of its various internal #include's) appears to be 
the culprit.  When windows.h is included, "interface" gets defined as a special 
keyword (this is also picked up and highlighted as a keyword under the Visual 
Studio editor).

ANSI C and compiler vendors are supposed to prefix reserved words with 
underscores, or end reserved words with "_t".  But hey, Microsoft makes up its 
own rules.  As it currently stands freetype.h and several other FT2 header 
files cannot be included within the same source file if windows.h is also 
included.

I know this goes against the grain, but it would save Windows users some 
trouble if "interface" wasn't used for symbols within FT2.

-Jack



At 12:58 PM 2/17/2000 -0800, Jack Davis wrote:
>When compiling a FreeType2 sample program under Microsoft Visual C (v6), 
>Visual C treats "interface" as a keyword and flags references to "interface" 
>as an error in freetype.h (in the Visual C editor, "interface" also shows up 
>highlighted in blue recognized as a keyword).  For example:
>
>    EXPORT_DEF
>    int  FT_Decompose_Outline( FT_Outline*        outline,
>                               FT_Outline_Funcs*  interface,   <--- error!!
>                               void*              user );
>
>is flagged with an error.  Changing the word "interface" to something else 
>makes Visual C happy:
>
>    EXPORT_DEF
>    int  FT_Decompose_Outline( FT_Outline*        outline,
>                               FT_Outline_Funcs*  funcInterface, <--- ok!!
>                               void*              user );
>
>There's only two places where "interface" is used, and in the function 
>prototypes it's easy to change and doesn't effect anything.
>
>ftoutln.h, however, #includes <ftobjs.h> which then #includes <ftconfig.h>, 
><ftsystem.h> and <ftdriver.h>  (ftoutln.h is needed for the function prototype 
>of FT_Get_Outline_Bitmap).  ftdriver.h also has a function prototype using 
>"interface" (changeable without effecting anything else).  The real killer is 
>that ftobjs.h uses a structure with a variable name "interface":
>
>    typedef struct  FT_DriverRec_
>    {
>      FT_Library          library;
>      FT_Memory           memory;
>      FT_Generic          generic;
>      FT_DriverInterface  interface;    // <---- VC v6 error!
>      FT_FormatInterface  format;
>      FT_Int              version;      /* driver version     */
>      FT_String*          description;  /* format description */
>      FT_ListRec          faces_list;   /* driver's faces list    */
>      void*               extensions;
>    } FT_DriverRec;
>
>ftobjs.h(307) : error C2236: unexpected 'struct' '$S1'
>ftobjs.h(307) : error C2027: use of undefined type '$S1'
>ftobjs.h(307) : see declaration of '$S1'
>
>Unfortunately changing the word "interface" here would also mean changing all 
>references to it in the FT2 code.
>
>Has anyone experience this behavior in VC6 before where "interface" is treated 
>as a reserved keyword?  "interface" seems to have been promoted to a keyword 
>in support of COM, but I've searched through the MSDN docs but can't find any 
>reference to compiler switch or "define" that controls this behavior.  
>Interestingly, my freetype library build using Visual C seems to compile fine, 
>this only happens when compiling my test program.
>
>Thanks for any suggestions,
>Jack
>
>
>PS: For the time being I've temporarily patched my version of freetype.h and 
>added the FT_Get_Outline_Bitmap() prototype directly in my application header 
>file so I don't have to #include <ftoutln.h>.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]