[Mesa-dev] Mesa (master): glsl: Add using statements for standard library functions.

Jose Fonseca jfonseca at vmware.com
Thu Feb 3 22:36:51 PST 2011


This is very odd behavior from Sun's compiler -- unless we include cstdio, printf should be available, not std::printf.

Jose

________________________________________
From: mesa-commit-bounces+jfonseca=vmware.com at lists.freedesktop.org [mesa-commit-bounces+jfonseca=vmware.com at lists.freedesktop.org] On Behalf Of Vinson Lee [vlee at kemper.freedesktop.org]
Sent: Friday, February 04, 2011 3:27
To: mesa-commit at lists.freedesktop.org
Subject: Mesa (master): glsl: Add using statements for standard library functions.

Module: Mesa
Branch: master
Commit: 61c59234f916406512b3591f46599cc29a5d8e23
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=61c59234f916406512b3591f46599cc29a5d8e23

Author: Vinson Lee <vlee at vmware.com>
Date:   Thu Feb  3 19:19:12 2011 -0800

glsl: Add using statements for standard library functions.

Standard library functions in C++ are in the std namespace. When using
C++-style header files for the standard library, some compilers, such as
Sun Studio, provide symbols only for the std namespace and not for the
global namespace.

This patch adds using statements for standard library functions. Another
option could have been to prepend standard library function calls with
'std::'.

This patch fixes several compilation errors with Sun Studio.

---

 src/glsl/ast_expr.cpp                 |    2 ++
 src/glsl/ast_type.cpp                 |    2 ++
 src/glsl/hir_field_selection.cpp      |    2 ++
 src/glsl/ir_print_visitor.cpp         |    3 +++
 src/glsl/ir_validate.cpp              |    3 +++
 src/glsl/lower_mat_op_to_vec.cpp      |    3 +++
 src/glsl/opt_constant_propagation.cpp |    2 ++
 src/glsl/opt_constant_variable.cpp    |    3 +++
 src/glsl/opt_dead_code.cpp            |    2 ++
 src/glsl/opt_dead_code_local.cpp      |    2 ++
 src/glsl/opt_dead_functions.cpp       |    2 ++
 src/glsl/opt_structure_splitting.cpp  |    3 +++
 src/glsl/opt_swizzle_swizzle.cpp      |    2 ++
 src/glsl/opt_tree_grafting.cpp        |    2 ++
 14 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_expr.cpp b/src/glsl/ast_expr.cpp
index 4e83dec..974beb9 100644
--- a/src/glsl/ast_expr.cpp
+++ b/src/glsl/ast_expr.cpp
@@ -24,6 +24,8 @@
 #include <cassert>
 #include "ast.h"

+using std::printf;
+
 const char *
 ast_expression::operator_string(enum ast_operators op)
 {
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index d140774..5ddfeec 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -27,6 +27,8 @@ extern "C" {
 #include "program/symbol_table.h"
 }

+using std::printf;
+
 void
 ast_type_specifier::print(void) const
 {
diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp
index 3c33127..995f284 100644
--- a/src/glsl/hir_field_selection.cpp
+++ b/src/glsl/hir_field_selection.cpp
@@ -27,6 +27,8 @@
 #include "ast.h"
 #include "glsl_types.h"

+using std::strcmp;
+
 ir_rvalue *
 _mesa_ast_field_selection_to_hir(const ast_expression *expr,
                                 exec_list *instructions,
diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp
index 82ccc72..be76945 100644
--- a/src/glsl/ir_print_visitor.cpp
+++ b/src/glsl/ir_print_visitor.cpp
@@ -25,6 +25,9 @@
 #include "glsl_types.h"
 #include "glsl_parser_extras.h"

+using std::printf;
+using std::strncmp;
+
 static void print_type(const glsl_type *t);

 void
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 44d7549..b0dd6c2 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -39,6 +39,9 @@
 #include "program/hash_table.h"
 #include "glsl_types.h"

+using std::abort;
+using std::printf;
+
 class ir_validate : public ir_hierarchical_visitor {
 public:
    ir_validate()
diff --git a/src/glsl/lower_mat_op_to_vec.cpp b/src/glsl/lower_mat_op_to_vec.cpp
index 8cbbfa7..bdc53a1 100644
--- a/src/glsl/lower_mat_op_to_vec.cpp
+++ b/src/glsl/lower_mat_op_to_vec.cpp
@@ -35,6 +35,9 @@
 #include "ir_expression_flattening.h"
 #include "glsl_types.h"

+using std::abort;
+using std::printf;
+
 class ir_mat_op_to_vec_visitor : public ir_hierarchical_visitor {
 public:
    ir_mat_op_to_vec_visitor()
diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp
index e1f6889..1fff717 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -41,6 +41,8 @@
 #include "ir_optimization.h"
 #include "glsl_types.h"

+using std::memset;
+
 class acp_entry : public exec_node
 {
 public:
diff --git a/src/glsl/opt_constant_variable.cpp b/src/glsl/opt_constant_variable.cpp
index 8068d0c..1f51da6 100644
--- a/src/glsl/opt_constant_variable.cpp
+++ b/src/glsl/opt_constant_variable.cpp
@@ -37,6 +37,9 @@
 #include "ir_optimization.h"
 #include "glsl_types.h"

+using std::calloc;
+using std::free;
+
 struct assignment_entry {
    exec_node link;
    int assignment_count;
diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp
index cb500d2..f47b961 100644
--- a/src/glsl/opt_dead_code.cpp
+++ b/src/glsl/opt_dead_code.cpp
@@ -32,6 +32,8 @@
 #include "ir_variable_refcount.h"
 #include "glsl_types.h"

+using std::printf;
+
 static bool debug = false;

 /**
diff --git a/src/glsl/opt_dead_code_local.cpp b/src/glsl/opt_dead_code_local.cpp
index 2610b69..88dcdc2 100644
--- a/src/glsl/opt_dead_code_local.cpp
+++ b/src/glsl/opt_dead_code_local.cpp
@@ -38,6 +38,8 @@
 #include "ir_optimization.h"
 #include "glsl_types.h"

+using std::printf;
+
 static bool debug = false;

 class assignment_entry : public exec_node
diff --git a/src/glsl/opt_dead_functions.cpp b/src/glsl/opt_dead_functions.cpp
index ceb7908..d72eb61 100644
--- a/src/glsl/opt_dead_functions.cpp
+++ b/src/glsl/opt_dead_functions.cpp
@@ -32,6 +32,8 @@
  #include "ir_expression_flattening.h"
  #include "glsl_types.h"

+ using std::strcmp;
+
  class signature_entry : public exec_node
  {
  public:
diff --git a/src/glsl/opt_structure_splitting.cpp b/src/glsl/opt_structure_splitting.cpp
index 014407c..8686da0 100644
--- a/src/glsl/opt_structure_splitting.cpp
+++ b/src/glsl/opt_structure_splitting.cpp
@@ -38,6 +38,9 @@
 #include "ir_rvalue_visitor.h"
 #include "glsl_types.h"

+using std::printf;
+using std::strcmp;
+
 static bool debug = false;

 // XXX using variable_entry2 here to avoid collision (MSVC multiply-defined
diff --git a/src/glsl/opt_swizzle_swizzle.cpp b/src/glsl/opt_swizzle_swizzle.cpp
index bc442fa..8d0e105 100644
--- a/src/glsl/opt_swizzle_swizzle.cpp
+++ b/src/glsl/opt_swizzle_swizzle.cpp
@@ -32,6 +32,8 @@
 #include "ir_optimization.h"
 #include "glsl_types.h"

+using std::memset;
+
 class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor {
 public:
    ir_swizzle_swizzle_visitor()
diff --git a/src/glsl/opt_tree_grafting.cpp b/src/glsl/opt_tree_grafting.cpp
index 1ef940f..a85ba82 100644
--- a/src/glsl/opt_tree_grafting.cpp
+++ b/src/glsl/opt_tree_grafting.cpp
@@ -54,6 +54,8 @@
 #include "ir_optimization.h"
 #include "glsl_types.h"

+using std::printf;
+
 static bool debug = false;

 class ir_tree_grafting_visitor : public ir_hierarchical_visitor {

_______________________________________________
mesa-commit mailing list
mesa-commit at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit


More information about the mesa-dev mailing list