Page MenuHome

Commit e3e23f7746977 breaks build with openexr
Closed, ResolvedPublic

Description

Blender Version
Broken: rBe3e23f774697782424647d8a12792dbc768501ad
Worked: rB83c9109926677b6b6a75ccb36ae0017733e8c8a2

Short description of error
Commit rBe3e23f77 causes BLI_Math_base.h to be included before openexr headers when compiling openexr_api.cpp which leads to the BLI_Math_base.h acosf() macro conflicting with ::acosf()

In file included from /home/shane/Projects/blender-bits/blender-trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp:85:
In file included from /usr/local/include/OpenEXR/ImathBox.h:65:
In file included from /usr/local/include/OpenEXR/ImathVec.h:48:
/usr/local/include/OpenEXR/ImathMath.h:127:45: error: expected unqualified-id
   static float acos  (float x)                 {return ::acosf (x);}   
                                                          ^
/home/shane/Projects/blender-bits/blender-trunk/blender/source/blender/blenlib/BLI_math_base.h:108:19: note: expanded from macro 'acosf'
#define acosf(a) ((float)acos(a))
                  ^

Moving #include "IMB_colormanagement.h" to after the openexr headers and keeping within an extern "C" resolves this for me.

diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index ecef621..d4b4882 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -71,9 +71,6 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
 #include "IMB_allocimbuf.h"
 #include "IMB_metadata.h"
 
-#include "IMB_colormanagement.h"
-#include "IMB_colormanagement_intern.h"
-
 #include "openexr_multi.h"
 }
 
@@ -104,6 +101,13 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void)
 #include <ImfPartType.h>
 #include <ImfPartHelper.h>
 
+extern "C"
+{
+/* including these before <Imf*> breaks compile with conflicting acosf() definitions */
+#include "IMB_colormanagement.h"
+#include "IMB_colormanagement_intern.h"
+}
+
 using namespace Imf;
 using namespace Imath;

Details

Type
Bug

Event Timeline

Shane Ambler (sambler) updated the task description. (Show Details)
Shane Ambler (sambler) raised the priority of this task from to Needs Triage by Developer.
Shane Ambler (sambler) set Type to Bug.

For the future, from the report guidelines:

What not to report here
Compile or build issues, ask on #blendercoders or mail bf-committers

Sergey Sharybin (sergey) closed this task as Resolved.Jan 26 2016, 10:00 AM

Committed the change now.