[Mesa-dev] [PATCH 7/9] glsl: Make foreach macros usable from C by adding struct keyword.

Petri Latvala petri.latvala at intel.com
Tue Jun 10 23:59:44 PDT 2014


On 06/10/2014 10:20 PM, Ian Romanick wrote:
> I did a little more research.  Looking at the commit history, it must
> just be an MSVC thing:
>
> commit 78d3cfb5b4fe1dbe052f87458e62cc2be2ecf171
> Author: Brian Paul <brianp at vmware.com>
> Date:   Sun Nov 4 16:43:44 2012 -0700
>
>      glsl: remove incorrect 'struct' keyword
>
>      ir_variable is a class, not a struct.  Fixes an MSVC warning.
>
>      Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
>
> So, I think it is just class vs struct (and not struct vs nothing) that
> causes the warning.
>


Mixing class and struct is fine in the Itanium ABI (the ABI used by gcc 
on Linux), they're both mangled the same. On Windows, the mangling is 
different and mixing class and struct will actually cause problems. 
Usually the problem is a failure to link.

For the kicks of it, clang++ has -Wmismatched-tags (part of -Wall) that 
will warn about mixing.

(As far as the C++ standard is concerned, `struct' class-key, `class' 
class-key and `union' class-key create "classes")

In a nutshell, for Windows builds, struct and class must match. For 
testing on Linux, CXX=clang++ CXXFLAGS=-Werror=mismatched-tags.

-- 
Petri Latvala



More information about the mesa-dev mailing list