[Mesa-dev] Odd error while compiling Haiku softpipe wrapper code

Brian Paul brian.e.paul at gmail.com
Sun Nov 25 09:00:54 PST 2012


On Sat, Nov 24, 2012 at 4:38 PM, Alexander von Gluck IV
<kallisti5 at unixzen.com> wrote:
> I'm working on some wrapper code for Haiku softpipe driver, and I stumbled
> across the following strange build error when including sp_context.h: (Mesa
> 9.0)
>
> In file included from
> ../../../../generated/build_packages/mesa-9.0-x86-gcc4-2012-11-17/src/gallium/drivers/softpipe/sp_context.h:36:0,
>                  from HaikuSoftPipe.cpp:14:
> ../../../../generated/build_packages/mesa-9.0-x86-gcc4-2012-11-17/src/gallium/auxiliary/draw/draw_vertex.h:
> In function 'size_t draw_vinfo_size(const vertex_info*)':
> ../../../../generated/build_packages/mesa-9.0-x86-gcc4-2012-11-17/src/gallium/auxiliary/draw/draw_vertex.h:96:11:
> error: 'a' cannot appear in a constant-expression
> ../../../../generated/build_packages/mesa-9.0-x86-gcc4-2012-11-17/src/gallium/auxiliary/draw/draw_vertex.h:96:11:
> error: '->' cannot appear in a constant-expression
>
>
> The error seems pretty cut and dry... not sure why Gallium compiles though.
> The only thing I can think of is that maybe Mesa throws in some buildflag to
> ignore the error or there is a missing header dependency in
> auxiliary/draw/draw_vertex.h.

Which version of gcc are you using?

The following change should work:

diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/dr
index c87c3d8..e7f4c62 100644
--- a/src/gallium/auxiliary/draw/draw_vertex.h
+++ b/src/gallium/auxiliary/draw/draw_vertex.h
@@ -94,7 +94,7 @@ struct vertex_info
 static INLINE size_t
 draw_vinfo_size( const struct vertex_info *a )
 {
-   return offsetof(const struct vertex_info, attrib[a->num_attribs]);
+   return (const char *) &a->attrib[a->num_attribs] - (const char *) a;
 }

 static INLINE int



-Brian


More information about the mesa-dev mailing list