[Mesa-dev] [PATCH 7/9] glsl: Make foreach macros usable from C by adding struct keyword.
Ian Romanick
idr at freedesktop.org
Tue Jun 10 12:20:50 PDT 2014
On 06/10/2014 12:06 PM, Matt Turner wrote:
> On Tue, Jun 10, 2014 at 11:38 AM, Ian Romanick <idr at freedesktop.org> wrote:
>> On 06/10/2014 11:00 AM, Matt Turner wrote:
>>> ---
>>> src/glsl/list.h | 22 +++++++++++-----------
>>> 1 file changed, 11 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/src/glsl/list.h b/src/glsl/list.h
>>> index da81062..803aab5 100644
>>> --- a/src/glsl/list.h
>>> +++ b/src/glsl/list.h
>>> @@ -556,13 +556,13 @@ inline void exec_node::insert_before(exec_list *before)
>>> /**
>>> * This version is safe even if the current node is removed.
>>> */
>>> -#define foreach_list_safe(__node, __list) \
>>> - for (exec_node * __node = (__list)->head, * __next = __node->next \
>>> - ; __next != NULL \
>>> +#define foreach_list_safe(__node, __list) \
>>> + for (struct exec_node * __node = (__list)->head, * __next = __node->next \
>>> + ; __next != NULL \
>>> ; __node = __next, __next = __next->next)
>>
>> Did you notice if this adds any warnings in C++ uses? I seem to recall
>> the compiler squaking if you mixed uses with and without struct. Or
>> maybe that was just if you mixed struct and class...
>
> Yep, no new warnings.
>
> I tried a little test program
> % cat t.cpp
> class asdf {
> int x;
> };
>
> void f() {
> asdf a;
> struct asdf b;
> class asdf c;
> }
>
> and I can't make it generate warnings (other than unused variables)
> regardless of whether I define asdf as a class or a struct.
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.
More information about the mesa-dev
mailing list