Bug 96235 - st_nir.h:34: error: redefinition of typedef ‘nir_shader’
Summary: st_nir.h:34: error: redefinition of typedef ‘nir_shader’
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2016-05-27 05:03 UTC by Vinson Lee
Modified: 2016-07-01 07:21 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Vinson Lee 2016-05-27 05:03:35 UTC
mesa: 4ccf8c952abb471f94d6f40786d896723f94c0ea (master 11.3.0-devel)

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


  CC     state_tracker/st_nir_lower_builtin.lo
In file included from state_tracker/st_nir_lower_builtin.c:61:
state_tracker/st_nir.h:34: error: redefinition of typedef ‘nir_shader’
../../src/compiler/nir/nir.h:1828: note: previous declaration of ‘nir_shader’ was here
Comment 1 Emil Velikov 2016-05-27 09:55:34 UTC
Using the forward declaration allows us to avoid including the nir.h header, thus keeping headers include chain shorter and less things get rebuild as a result.

On the other hand, typedef redefinition is a C11 feature (iirc) which we cannot enforce atm. There was a lengthy discussion about killing off the typedefs in NIR, as they made sense in the C++ GLSL but not the C based NIR.

Don't recall the conclusion of the thread, but fwiw I'm for killing the typedefs thus being able to build mesa with GCC 4.x series and (in due time) killing off the unneeded includes of nir*.h and replacing them with fwd declarations.
Comment 2 Vinson Lee 2016-07-01 07:21:31 UTC
commit 3fea592c4eb26f6652bef1e5dc430e2296e14bac
Author: Vinson Lee <vlee@freedesktop.org>
Date:   Wed Jun 29 20:15:03 2016 -0700

    mesa/st: Use 'struct nir_shader' instead of 'nir_shader'.
    
    Fix this build error with GCC 4.4.
    
      CC     state_tracker/st_nir_lower_builtin.lo
    In file included from state_tracker/st_nir_lower_builtin.c:61:
    state_tracker/st_nir.h:34: error: redefinition of typedef ‘nir_shader’
    ../../src/compiler/nir/nir.h:1830: note: previous declaration of ‘nir_shader’ was here
    
    Suggested-by: Rob Clark <robdclark@gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96235
    Signed-off-by: Vinson Lee <vlee@freedesktop.org>
    Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
    Reviewed-by: Rob Clark <robdclark@gmail.com>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.