[Mesa-dev] [PATCH] gl.h, gl2.h, gallium: use stdbool.h for GLboolean and boolean

Ian Romanick idr at freedesktop.org
Thu Oct 14 14:33:39 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nicolas Kaiser wrote:
> This patch adds support for the compiler built-in Boolean type
> to GLboolean and the "boolean" type in gallium
> by bringing them in line with the "bool" type in stdbool.h.
> 
> Signed-off-by: Nicolas Kaiser <nikai at nikai.net>
> ---
>  include/GL/gl.h                       |    7 ++++---
>  include/GLES/gl.h                     |    7 ++++---
>  include/GLES2/gl2.h                   |    7 ++++---
>  src/gallium/include/pipe/p_compiler.h |    2 +-
>  4 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/include/GL/gl.h b/include/GL/gl.h
> index 8e5f138..2d66053 100644
> --- a/include/GL/gl.h
> +++ b/include/GL/gl.h
> @@ -149,11 +149,12 @@ extern "C" {
>  #define GL_ARB_imaging   1
>  
>  
> +#include <stdbool.h>

In spite of my dislike of the GL types, this doesn't seem useful.
Moreover, the GLES headers come from Khronos and we don't get to change
those.

[snip]

> diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h
> index 3d6b5b5..b12399b 100644
> --- a/src/gallium/include/pipe/p_compiler.h
> +++ b/src/gallium/include/pipe/p_compiler.h
> @@ -72,7 +72,7 @@ typedef unsigned short     ushort;
>  #endif
>  typedef unsigned char      ubyte;
>  
> -typedef unsigned char boolean;
> +typedef bool               boolean;
>  #ifndef TRUE
>  #define TRUE  true
>  #endif

Why not just stop using boolean in favor of bool?  The ISO C committee
was kind enough to define types that work everywhere (provide you have
the appropriate header files).  Defining new names for those types is
tantamount to code obfuscation.  Don't even get me started about ubyte,
ushort, and friends.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAky3dzEACgkQX1gOwKyEAw+WqgCZARnHt2IOatxuISS0h49y7X6D
CJMAnjdLzU/Qe4VolXldJ8SX6baOVwx8
=LZDT
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list