[pytango] 70/483: Fix warnings and errors in windows compilation

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.

commit 60c02aa9d9c7b0bde083d243bafadabd6fd3e428
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed Nov 30 15:35:13 2011 +0000

    Fix warnings and errors in windows compilation
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@18519 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 setup.py                         |  14 ++--
 src/device_attribute.h           |   2 +-
 src/device_attribute_numpy.hpp   |   3 +
 src/exception.cpp                |   1 +
 src/exception.h                  |   4 +-
 src/fast_from_py.h               |   4 +-
 src/server/device_impl.cpp       |   5 ++
 src/server/encoded_attribute.cpp | 150 ++++++++++++++++++++++-----------------
 src/server/tango_util.cpp        |   2 +-
 9 files changed, 107 insertions(+), 78 deletions(-)

diff --git a/setup.py b/setup.py
index 41a90cc..052b1a6 100644
--- a/setup.py
+++ b/setup.py
@@ -352,7 +352,9 @@ def main():
         library_dirs += [ os.path.join(OMNI_ROOT, 'lib', 'x86_win32') ]
         
         extra_compile_args += [
-            '/EHsc'
+            '/EHsc',
+            '/wd4005', # supress redefinition of HAVE_STRFTIME between python and omniORB
+            '/wd4996', # same as /D_SCL_SECURE_NO_WARNINGS
         ]
 
         extra_link_args += []
@@ -418,10 +420,12 @@ def main():
     include_dirs = uniquify(include_dirs)
     library_dirs = uniquify(library_dirs)
 
-    _cppfiles_exclude = []
-    _cppfiles  = [ os.path.join('src',fname) for fname in os.listdir('src') if fname.endswith('.cpp') and not fname in _cppfiles_exclude]
-    _cppfiles += [ os.path.join('src','server',fname) for fname in os.listdir(os.path.join('src','server')) if fname.endswith('.cpp') and not fname in _cppfiles_exclude]
-
+    _clientfiles = [ os.path.join('src',fname) for fname in os.listdir('src') if fname.endswith('.cpp') ]
+    _clientfiles.sort()
+    _serverfiles = [ os.path.join('src','server',fname) for fname in os.listdir(os.path.join('src','server')) if fname.endswith('.cpp') ]
+    _serverfiles.sort()
+    _cppfiles = _clientfiles + _serverfiles
+    
     _pytango = Extension(
         name               = '_PyTango',
         sources            = _cppfiles,
diff --git a/src/device_attribute.h b/src/device_attribute.h
index 66731af..896b6a8 100644
--- a/src/device_attribute.h
+++ b/src/device_attribute.h
@@ -84,7 +84,7 @@ namespace PyDeviceAttribute {
                         }
                     }
                 }
-                catch(Tango::DevFailed &df)
+                catch(Tango::DevFailed &)
                 {
                     // if we fail to get info about the missing attributes from
                     // the server (because it as shutdown, for example) we assume
diff --git a/src/device_attribute_numpy.hpp b/src/device_attribute_numpy.hpp
index 90eeb92..60147c4 100644
--- a/src/device_attribute_numpy.hpp
+++ b/src/device_attribute_numpy.hpp
@@ -26,6 +26,9 @@
 // device_attribute.cpp, and should only be included there.
 
 #pragma once
+
+// Because of line: object iter_guard(handle<>(iter));
+#pragma warning(disable:4930)
 
 namespace PyDeviceAttribute {
 
diff --git a/src/exception.cpp b/src/exception.cpp
index 218be7c..8e0d242 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -28,6 +28,7 @@
 #include <string>
 
 #include "pytgutils.h"
+#include "exception.h"
 
 using namespace boost::python;
 
diff --git a/src/exception.h b/src/exception.h
index be56e17..fc9e8f8 100644
--- a/src/exception.h
+++ b/src/exception.h
@@ -70,7 +70,7 @@ void throw_python_generic_exception(PyObject *type=NULL, PyObject *value=NULL,
 void handle_python_exception(boost::python::error_already_set &eas);
 
 #define SAFE_CATCH_REPORT(meth_name) \
-    catch(boost::python::error_already_set &eas) \
+    catch(boost::python::error_already_set &) \
     { \
         std::cerr << "PyTango generated an unexpected python exception in " \
                   << meth_name << "." << std::endl \
@@ -94,7 +94,7 @@ void handle_python_exception(boost::python::error_already_set &eas);
     }
 
 #define SAFE_CATCH_INFORM(meth_name) \
-    catch(boost::python::error_already_set &eas) \
+    catch(boost::python::error_already_set &) \
     { \
         std::cerr << meth_name << " generated the following python exception:" << std::endl; \
         PyErr_Print(); \
diff --git a/src/fast_from_py.h b/src/fast_from_py.h
index a053aef..8d96be8 100644
--- a/src/fast_from_py.h
+++ b/src/fast_from_py.h
@@ -149,11 +149,11 @@ struct from_py<tangoTypeConst> \
                     boost::python::throw_error_already_set();  \
             } \
             if (TangoScalarTypeLimits::is_integer) { \
-                if (cpy_value > TangoScalarTypeLimits::max()) { \
+                if (cpy_value > (cpy_type)TangoScalarTypeLimits::max()) { \
                     PyErr_SetString(PyExc_OverflowError, "Value is too large."); \
                     boost::python::throw_error_already_set(); \
                 } \
-                if (cpy_value < TangoScalarTypeLimits::min()) { \
+                if (cpy_value < (cpy_type)TangoScalarTypeLimits::min()) { \
                     PyErr_SetString(PyExc_OverflowError, "Value is too small."); \
                     boost::python::throw_error_already_set(); \
                 } \
diff --git a/src/server/device_impl.cpp b/src/server/device_impl.cpp
index 89a9b34..bceac42 100644
--- a/src/server/device_impl.cpp
+++ b/src/server/device_impl.cpp
@@ -34,6 +34,9 @@
 #include "server/attribute.h"
 #include "to_py.h"
 
+#pragma warning( push )
+#pragma warning( disable : 4250 ) // C4250 - 'class1' : inherits 'class2::member' 
+
 extern const char *param_must_be_seq;
 
 using namespace boost::python;
@@ -1330,3 +1333,5 @@ void export_device_impl()
     ;
     implicitly_convertible<auto_ptr<Device_4ImplWrap>, auto_ptr<Tango::Device_4Impl> >();
 }
+
+#pragma warning( pop ) // C4250
diff --git a/src/server/encoded_attribute.cpp b/src/server/encoded_attribute.cpp
index ebb6eb1..2823432 100644
--- a/src/server/encoded_attribute.cpp
+++ b/src/server/encoded_attribute.cpp
@@ -28,9 +28,13 @@
 
 using namespace boost::python;
 
+const int i = 1;
+#define IS_BIGENDIAN() ( (*(char*)&i) == 0 )
+
 namespace PyEncodedAttribute
 {
-    /// This callback is run to delete char* objects.
+
+	/// This callback is run to delete char* objects.
     /// It is called by python. The array was associated with an attribute
     /// value object that is not being used anymore.
     /// @param ptr_ The array object.
@@ -44,7 +48,7 @@ namespace PyEncodedAttribute
         else if (2 == t)
             delete [] (static_cast<unsigned short*>(ptr_));
         else if (4 == t)
-            delete [] (static_cast<uint32_t*>(ptr_));
+			delete [] (static_cast<Tango::DevULong*>(ptr_));
     }
     
     void encode_gray8(Tango::EncodedAttribute &self, object py_value, int w, int h)
@@ -70,9 +74,11 @@ namespace PyEncodedAttribute
 #endif
         // It must be a py sequence
         // we are sure that w and h are given by python (see encoded_attribute.py)
-        unsigned char b[w*h];
-        buffer = b;
-        unsigned char *p = b;
+		const int length = w*h;
+	    unsigned char *raw_b = new unsigned char[length];
+		auto_ptr<unsigned char> b(raw_b);
+        buffer = raw_b;
+        unsigned char *p = raw_b;
         int w_bytes = w;
         for (long y=0; y<h; ++y)
         {
@@ -133,7 +139,7 @@ namespace PyEncodedAttribute
                     else if (PyInt_Check(cell) || PyLong_Check(cell))
                     {
                         long byte = PyLong_AsLong(cell);
-                        if (byte==-1 and PyErr_Occurred())
+                        if (byte==-1 && PyErr_Occurred())
                         {
                             Py_DECREF(row);
                             Py_DECREF(cell);
@@ -182,9 +188,11 @@ namespace PyEncodedAttribute
 #endif
         // It must be a py sequence
         // we are sure that w and h are given by python (see encoded_attribute.py)
-        unsigned char b[w*h];
-        buffer = b;
-        unsigned char *p = b;
+		const int length = w*h;
+        unsigned char *raw_b = new unsigned char[length];
+        auto_ptr<unsigned char> b(raw_b);
+		buffer = raw_b;
+        unsigned char *p = raw_b;
         int w_bytes = w;
         for (long y=0; y<h; ++y)
         {
@@ -245,7 +253,7 @@ namespace PyEncodedAttribute
                     else if (PyInt_Check(cell) || PyLong_Check(cell))
                     {
                         long byte = PyLong_AsLong(cell);
-                        if (byte==-1 and PyErr_Occurred())
+                        if (byte==-1 && PyErr_Occurred())
                         {
                             Py_DECREF(row);
                             Py_DECREF(cell);
@@ -294,9 +302,11 @@ namespace PyEncodedAttribute
 #endif
         // It must be a py sequence
         // we are sure that w and h are given by python (see encoded_attribute.py)
-        unsigned short b[w*h];
-        buffer = b;
-        unsigned short *p = b;
+		const int length = w*h;
+        unsigned short *raw_b = new unsigned short[length];
+        auto_ptr<unsigned short> b(raw_b);
+		buffer = raw_b;
+        unsigned short *p = raw_b;
         int w_bytes = 2*w;
         for (long y=0; y<h; ++y)
         {
@@ -356,7 +366,7 @@ namespace PyEncodedAttribute
                     }
                     else if (PyInt_Check(cell) || PyLong_Check(cell))
                     {
-                        unsigned short word = PyLong_AsUnsignedLong(cell);
+                        unsigned short word = (unsigned short)PyLong_AsUnsignedLong(cell);
                         if (PyErr_Occurred())
                         {
                             Py_DECREF(row);
@@ -402,9 +412,11 @@ namespace PyEncodedAttribute
 #endif
         // It must be a py sequence
         // we are sure that w and h are given by python (see encoded_attribute.py)
-        unsigned char b[w*h];
-        buffer = b;
-        unsigned char *p = b;
+		const int length = w*h;
+        unsigned char *raw_b = new unsigned char[length];
+        auto_ptr<unsigned char> b(raw_b);
+		buffer = raw_b;
+        unsigned char *p = raw_b;
         int w_bytes = 3*w;
         for (long y=0; y<h; ++y)
         {
@@ -467,23 +479,23 @@ namespace PyEncodedAttribute
                     else if (PyInt_Check(cell) || PyLong_Check(cell))
                     {
                         long byte = PyLong_AsLong(cell);
-                        if (byte==-1 and PyErr_Occurred())
+                        if (byte==-1 && PyErr_Occurred())
                         {
                             Py_DECREF(row);
                             Py_DECREF(cell);
                             boost::python::throw_error_already_set();
                         }
-                        if (BYTE_ORDER == LITTLE_ENDIAN)
+                        if (IS_BIGENDIAN())
                         {
-                            *p = (byte) & 0xFF; p++;
-                            *p = (byte >>  8) & 0xFF; p++;
-                            *p = (byte >> 16) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 16) & 0xFF; p++;
+                            *p = (unsigned char)(byte >>  8) & 0xFF; p++;
+                            *p = (unsigned char)(byte) & 0xFF; p++;
                         }
                         else
                         {
-                            *p = (byte >> 16) & 0xFF; p++;
-                            *p = (byte >>  8) & 0xFF; p++;
-                            *p = (byte) & 0xFF; p++;
+                            *p = (unsigned char)(byte) & 0xFF; p++;
+                            *p = (unsigned char)(byte >>  8) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 16) & 0xFF; p++;
                         }
                     }
                     Py_DECREF(cell);
@@ -514,9 +526,11 @@ namespace PyEncodedAttribute
 #endif
         // It must be a py sequence
         // we are sure that w and h are given by python (see encoded_attribute.py)
-        unsigned char b[w*h];
-        buffer = b;
-        unsigned char *p = b;
+		const int length = w*h;
+        unsigned char *raw_b = new unsigned char[length];
+        auto_ptr<unsigned char> b(raw_b);
+		buffer = raw_b;
+        unsigned char *p = raw_b;
         int w_bytes = 3*w;
         for (long y=0; y<h; ++y)
         {
@@ -579,23 +593,23 @@ namespace PyEncodedAttribute
                     else if (PyInt_Check(cell) || PyLong_Check(cell))
                     {
                         long byte = PyLong_AsLong(cell);
-                        if (byte==-1 and PyErr_Occurred())
+                        if (byte==-1 && PyErr_Occurred())
                         {
                             Py_DECREF(row);
                             Py_DECREF(cell);
                             boost::python::throw_error_already_set();
                         }
-                        if (BYTE_ORDER == LITTLE_ENDIAN)
+                        if (IS_BIGENDIAN())
                         {
-                            *p = (byte) & 0xFF; p++;
-                            *p = (byte >>  8) & 0xFF; p++;
-                            *p = (byte >> 16) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 16) & 0xFF; p++;
+                            *p = (unsigned char)(byte >>  8) & 0xFF; p++;
+                            *p = (unsigned char)(byte) & 0xFF; p++;
                         }
                         else
                         {
-                            *p = (byte >> 16) & 0xFF; p++;
-                            *p = (byte >>  8) & 0xFF; p++;
-                            *p = (byte) & 0xFF; p++;
+                            *p = (unsigned char)(byte) & 0xFF; p++;
+                            *p = (unsigned char)(byte >>  8) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 16) & 0xFF; p++;
                         }
                     }
                     Py_DECREF(cell);
@@ -626,9 +640,11 @@ namespace PyEncodedAttribute
 #endif
         // It must be a py sequence
         // we are sure that w and h are given by python (see encoded_attribute.py)
-        unsigned char b[w*h];
-        buffer = b;
-        unsigned char *p = b;
+		const int length = w*h;
+        unsigned char *raw_b = new unsigned char[length];
+        auto_ptr<unsigned char> b(raw_b);
+		buffer = raw_b;
+        unsigned char *p = raw_b;
         int w_bytes = 4*w;
         for (long y=0; y<h; ++y)
         {
@@ -692,25 +708,25 @@ namespace PyEncodedAttribute
                     else if (PyInt_Check(cell) || PyLong_Check(cell))
                     {
                         long byte = PyLong_AsLong(cell);
-                        if (byte==-1 and PyErr_Occurred())
+                        if (byte==-1 && PyErr_Occurred())
                         {
                             Py_DECREF(row);
                             Py_DECREF(cell);
                             boost::python::throw_error_already_set();
                         }
-                        if (BYTE_ORDER == LITTLE_ENDIAN)
+                        if (IS_BIGENDIAN())
                         {
-                            *p = (byte) & 0xFF; p++;
-                            *p = (byte >>  8) & 0xFF; p++;
-                            *p = (byte >> 16) & 0xFF; p++;
-                            *p = (byte >> 24) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 24) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 16) & 0xFF; p++;
+                            *p = (unsigned char)(byte >>  8) & 0xFF; p++;
+                            *p = (unsigned char)(byte) & 0xFF; p++;
                         }
                         else
                         {
-                            *p = (byte >> 24) & 0xFF; p++;
-                            *p = (byte >> 16) & 0xFF; p++;
-                            *p = (byte >>  8) & 0xFF; p++;
-                            *p = (byte) & 0xFF; p++;
+                            *p = (unsigned char)(byte) & 0xFF; p++;
+                            *p = (unsigned char)(byte >>  8) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 16) & 0xFF; p++;
+                            *p = (unsigned char)(byte >> 24) & 0xFF; p++;
                         }
                     }
                     Py_DECREF(cell);
@@ -1085,22 +1101,22 @@ namespace PyEncodedAttribute
                     {
                         long idx = 4*(y*width+x);
                         // data comes in in big endian format
-                        uint32_t data;
-                        if (BYTE_ORDER == LITTLE_ENDIAN)
+						Tango::DevULong data;
+                        if (IS_BIGENDIAN())
                         {
-                            idx +=3;
                             char *p = reinterpret_cast<char *>(&data);
-                            *p = ch_ptr[idx--]; ++p;
-                            *p = ch_ptr[idx--]; ++p;
-                            *p = ch_ptr[idx--]; ++p;
+                            *p = ch_ptr[idx++]; ++p;
+                            *p = ch_ptr[idx++]; ++p;
+                            *p = ch_ptr[idx++]; ++p;
                             *p = ch_ptr[idx];
                         }
                         else
                         {
+                            idx +=3;
                             char *p = reinterpret_cast<char *>(&data);
-                            *p = ch_ptr[idx++]; ++p;
-                            *p = ch_ptr[idx++]; ++p;
-                            *p = ch_ptr[idx++]; ++p;
+                            *p = ch_ptr[idx--]; ++p;
+                            *p = ch_ptr[idx--]; ++p;
+                            *p = ch_ptr[idx--]; ++p;
                             *p = ch_ptr[idx];
                         }
                         PyTuple_SetItem(row, x, PyLong_FromUnsignedLong(data));
@@ -1134,22 +1150,22 @@ namespace PyEncodedAttribute
                     {
                         long idx = 4*(y*width+x);
                         // data comes in in big endian format
-                        uint32_t data;
-                        if (BYTE_ORDER == LITTLE_ENDIAN)
+						Tango::DevULong data;
+                        if (IS_BIGENDIAN())
                         {
-                            idx +=3;
                             char *p = reinterpret_cast<char *>(&data);
-                            *p = ch_ptr[idx--]; ++p;
-                            *p = ch_ptr[idx--]; ++p;
-                            *p = ch_ptr[idx--]; ++p;
+                            *p = ch_ptr[idx++]; ++p;
+                            *p = ch_ptr[idx++]; ++p;
+                            *p = ch_ptr[idx++]; ++p;
                             *p = ch_ptr[idx];
                         }
                         else
                         {
+                            idx +=3;
                             char *p = reinterpret_cast<char *>(&data);
-                            *p = ch_ptr[idx++]; ++p;
-                            *p = ch_ptr[idx++]; ++p;
-                            *p = ch_ptr[idx++]; ++p;
+                            *p = ch_ptr[idx--]; ++p;
+                            *p = ch_ptr[idx--]; ++p;
+                            *p = ch_ptr[idx--]; ++p;
                             *p = ch_ptr[idx];
                         }
                         PyList_SetItem(row, x, PyLong_FromUnsignedLong(data));
diff --git a/src/server/tango_util.cpp b/src/server/tango_util.cpp
index e85a3ee..6bb95a1 100644
--- a/src/server/tango_util.cpp
+++ b/src/server/tango_util.cpp
@@ -73,7 +73,7 @@ Tango::DeviceClass* create_cpp_class(const std::string& class_name,
     if ((proc = GetProcAddress(mod,sym_name.c_str())) == NULL)
     {
         TangoSys_OMemStream o;
-        o << "Class " << cl_name << " does not have the C creator function "
+        o << "Class " << class_name << " does not have the C creator function "
              "(_create_<Class name>_class)" << ends;
 
         Tango::Except::throw_exception("API_ClassNotFound", o.str(),

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list