freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] Re: const char * (was RE: Mac OS X improvements)


From: Dave Williss
Subject: Re: [Freetype] Re: const char * (was RE: Mac OS X improvements)
Date: Tue, 11 Dec 2001 13:49:22 -0600

----- Original Message -----
From: "Paul Miller" <address@hidden>
To: <address@hidden>
Sent: Friday, December 07, 2001 9:43 AM
Subject: Re: [Freetype] Re: const char * (was RE: Mac OS X improvements)


>
> > >          I could be wrong on this one, but const isn't part of the C89
> > > standard - only the C9x one...
> >
> >Not to worry.  const is C89.
>
> That's what I thought. My XML parser (http://www.fxtech.com/xmlio) uses
> const liberally and I've never had a complaint.
>

I believe that virtually all compliers these days at least accept the const
keyword and that it's been part of the standard almost from the beginning
(if not all along).  The problem in the old days wasn't the compiler, but
the
standard libraries.  None of the standard library functions actually took
const pointers, so if you tried to use them, you ended up having to cast
away
the const-ness.

The solution I've seen in other open source projects is to #define CONST
in a config.h and use that.  For example...

    #ifdef NO_CONST
    #define CONST
    #else
    #define CONST const
    #endif

    void FT_Whatever(CONST char* something);

Then anybody who needs to use a compiler that doesn't understand const
can add the flag to define NO_CONST to their Makefile.

You can be sneaky and make you code look better by doing it more like...

    #ifdef NO_CONST
    #define const
    #endif

Then just go ahead and use const.

 -- Dave Williss
------
Meddle not in the affairs of dragons,
   for you are crunchy and taste good with catsup










reply via email to

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