Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Build fails with custom namespaces #1567

Open
barretpj opened this issue Sep 19, 2023 · 1 comment
Open

Regression: Build fails with custom namespaces #1567

barretpj opened this issue Sep 19, 2023 · 1 comment

Comments

@barretpj
Copy link

To avoid clashes with other apps, we build with -DOPENEXR_IMF_NAMESPACE=FL_Imf -DILMTHREAD_NAMESPACE=FL_IlmThread -DIEX_NAMESPACE=FL_Iex

Recent changes (between 3.1.5 and 3.2.0) have broken the build in this situation. This patch fixes them up:

diff -Naur openexr-3.2.0/src/wrappers/python/OpenEXR.cpp openexr-3.2.0-fl/src/wrappers/python/OpenEXR.cpp
--- openexr-3.2.0/src/wrappers/python/OpenEXR.cpp	2023-08-28 18:56:26.000000000 +0100
+++ openexr-3.2.0-fl/src/wrappers/python/OpenEXR.cpp	2023-09-19 10:06:34.100461770 +0100
@@ -92,8 +92,8 @@
 #endif
 
 using namespace std;
-using namespace Imf;
-using namespace Imath;
+using namespace IMF;
+using namespace IMATH_NAMESPACE;
 
 static PyObject *OpenEXR_error = NULL;
 static PyObject *pModuleImath;
@@ -155,7 +155,7 @@
       memcpy(c, PyString_AsString(data), PyString_Size(data));
       Py_DECREF(data);
     } else {
-      throw Iex::InputExc("file read failed");
+      throw IEX_NAMESPACE::InputExc("file read failed");
     }
     return 0;
 }
@@ -177,7 +177,7 @@
       Py_DECREF(rv);
       return (Int64)t;
     } else {
-      throw Iex::InputExc("tell failed");
+      throw IEX_NAMESPACE::InputExc("tell failed");
     }
 }
 
@@ -188,7 +188,7 @@
     if (data != NULL) {
         Py_DECREF(data);
     } else {
-      throw Iex::InputExc("seek failed");
+      throw IEX_NAMESPACE::InputExc("seek failed");
     }
 }
 
@@ -220,7 +220,7 @@
     if (data != NULL) {
       Py_DECREF(data);
     } else {
-      throw Iex::InputExc("file write failed");
+      throw IEX_NAMESPACE::InputExc("file write failed");
     }
 }
 
@@ -241,7 +241,7 @@
       Py_DECREF(rv);
       return (Int64)t;
     } else {
-      throw Iex::InputExc("tell failed");
+      throw IEX_NAMESPACE::InputExc("tell failed");
     }
 }
 
@@ -252,7 +252,7 @@
     if (data != NULL) {
         Py_DECREF(data);
     } else {
-      throw Iex::InputExc("seek failed");
+      throw IEX_NAMESPACE::InputExc("seek failed");
     }
 }
 
diff -Naur openexr-3.2.0/website/src/all.cpp openexr-3.2.0-fl/website/src/all.cpp
--- openexr-3.2.0/website/src/all.cpp	2023-08-28 18:56:26.000000000 +0100
+++ openexr-3.2.0-fl/website/src/all.cpp	2023-09-19 10:13:45.424049266 +0100
@@ -35,8 +35,8 @@
 #include <unistd.h>
 #endif
 
-using namespace Imath;
-using namespace Imf;
+using namespace IMATH_NAMESPACE;
+using namespace OPENEXR_IMF_NAMESPACE;
 
 using std::max;
 
diff -Naur openexr-3.2.0/website/src/C_IStream_read.cpp openexr-3.2.0-fl/website/src/C_IStream_read.cpp
--- openexr-3.2.0/website/src/C_IStream_read.cpp	2023-08-28 18:56:26.000000000 +0100
+++ openexr-3.2.0-fl/website/src/C_IStream_read.cpp	2023-09-19 10:06:59.782734926 +0100
@@ -8,9 +8,9 @@
         // determine what happened.
     
         if (ferror (_file))
-            Iex::throwErrnoExc();
+            IEX_NAMESPACE::throwErrnoExc();
         else
-            throw Iex::InputExc ("Unexpected end of file.");
+            throw IEX_NAMESPACE::InputExc ("Unexpected end of file.");
     }
     
     return !feof (_file);
diff -Naur openexr-3.2.0/website/src/MemoryMappedIStream_read.cpp openexr-3.2.0-fl/website/src/MemoryMappedIStream_read.cpp
--- openexr-3.2.0/website/src/MemoryMappedIStream_read.cpp	2023-08-28 18:56:26.000000000 +0100
+++ openexr-3.2.0-fl/website/src/MemoryMappedIStream_read.cpp	2023-09-19 10:07:07.901821279 +0100
@@ -2,10 +2,10 @@
 MemoryMappedIStream::read (char c[], int n)
 {
     if (_readPosition >= _fileLength)
-        throw Iex::InputExc ("Unexpected end of file.");
+        throw IEX_NAMESPACE::InputExc ("Unexpected end of file.");
     
     if (_readPosition + n > _fileLength)
-        throw Iex::InputExc ("Reading past end of file.");
+        throw IEX_NAMESPACE::InputExc ("Reading past end of file.");
 
     memcpy (c, _buffer + _readPosition, n);
 
diff -Naur openexr-3.2.0/website/src/MemoryMappedIStream_readMemoryMapped.cpp openexr-3.2.0-fl/website/src/MemoryMappedIStream_readMemoryMapped.cpp
--- openexr-3.2.0/website/src/MemoryMappedIStream_readMemoryMapped.cpp	2023-08-28 18:56:26.000000000 +0100
+++ openexr-3.2.0-fl/website/src/MemoryMappedIStream_readMemoryMapped.cpp	2023-09-19 10:06:46.743596241 +0100
@@ -2,10 +2,10 @@
 MemoryMappedIStream::readMemoryMapped (int n)
 {
     if (_readPosition >= _fileLength)
-        throw Iex::InputExc ("Unexpected end of file.");
+        throw IEX_NAMESPACE::InputExc ("Unexpected end of file.");
 
     if (_readPosition + n > _fileLength)
-        throw Iex::InputExc ("Reading past end of file.");
+        throw IEX_NAMESPACE::InputExc ("Reading past end of file.");
 
     char *data = _buffer + _readPosition;
 
@barretpj
Copy link
Author

Suggest CI builds are amended to include this as a normal test case so this doesn't keep happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant