bug-gnulib
[Top][All Lists]
Advanced

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

Re: Problem with stdbool.h redefining true/false even in C++


From: Michael Goffioul
Subject: Re: Problem with stdbool.h redefining true/false even in C++
Date: Wed, 29 Aug 2012 18:16:47 +0100

On Wed, Aug 29, 2012 at 6:13 PM, Paul Eggert <address@hidden> wrote:
On 08/29/2012 10:00 AM, John W. Eaton wrote:
> Why define true, false, and bool to anything when using C++?

Maybe it's for '#ifdef bool' but to be honest I'm just doing what
GCC does.  Perhaps you can ask the GCC developers why they do did
it that way....

My GCC stdbool.h is quite different:

#ifndef __cplusplus

#define bool    _Bool
#define true    1
#define false   0

#else /* __cplusplus */

/* Supporting <stdbool.h> in C++ is a GCC extension.  */
#define _Bool   bool
#define bool    bool
#define false   false
#define true    true

#endif /* __cplusplus */

/* Signal that all the definitions are present.  */
#define __bool_true_false_are_defined   1

 
Anyway, I'd be surprised if Octave cares whether true, false, and bool
are macros.  If it does, then it's broken on GNUish hosts anyway,
right?  And if it doesn't, the gnulib patch should work as-is.

It is/was a problem because the macros actually changed the type of "true" and "false". They were not of the native C++ "bool" type anymore, meaning that fun(true) could potentially calls a completely different implementation of fun (which is what happened in octave).

Michael.


reply via email to

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