[Mesa-dev] [PATCH] program: use extern "C" where appropriate in sampler.cpp

Brian Paul brianp at vmware.com
Tue Dec 16 13:40:57 PST 2014


On 12/16/2014 02:08 PM, Mark Janes wrote:
> `make check` fails to link test_vec4_copy_propagation after 6dac455e.
> ---
>   src/mesa/program/sampler.cpp | 5 ++---
>   src/mesa/program/sampler.h   | 7 +++++++
>   2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/program/sampler.cpp b/src/mesa/program/sampler.cpp
> index f8584c9..7754a41 100644
> --- a/src/mesa/program/sampler.cpp
> +++ b/src/mesa/program/sampler.cpp
> @@ -102,8 +102,7 @@ public:
>      ir_dereference *last;
>   };
>
> -
> -int
> +extern "C" int
>   _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
>   				struct gl_shader_program *shader_program,
>   				const struct gl_program *prog)
> @@ -135,7 +134,7 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
>   }
>
>
> -class ir_rvalue *
> +extern "C" class ir_rvalue *
>   _mesa_get_sampler_array_nonconst_index(class ir_dereference *sampler)
>   {
>      ir_dereference_array *deref_arr = sampler->as_dereference_array();
> diff --git a/src/mesa/program/sampler.h b/src/mesa/program/sampler.h
> index 61c7f58..d5faa40 100644
> --- a/src/mesa/program/sampler.h
> +++ b/src/mesa/program/sampler.h
> @@ -26,6 +26,9 @@
>   #ifndef SAMPLER_H
>   #define SAMPLER_H
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
>
>   int
>   _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
> @@ -35,5 +38,9 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
>   class ir_rvalue *
>   _mesa_get_sampler_array_nonconst_index(class ir_dereference *sampler);
>
> +#ifdef __cplusplus
> +}
> +#endif
> +
>
>   #endif /* SAMPLER_H */
>

I don't think this is right.  The functions in question are C++ 
functions and they're only called from .cpp files.  I don't see why 
C-style linkage is desired.

See https://bugs.freedesktop.org/show_bug.cgi?id=87371 for another 
approach.  Please test that patch if you can.

-Brian



More information about the mesa-dev mailing list