Skip to content

gabornoise.cpp compile error #160

Closed
cypod opened this Issue Sep 29, 2012 · 6 comments

3 participants

@cypod
cypod commented Sep 29, 2012

There is a compile time error with gabornoise.cpp :

[ 19%] Building CXX object liboslexec/CMakeFiles/oslexec.dir/gabornoise.cpp.o
~/dev/osl3/src/liboslexec/gabornoise.cpp:70:9: error: this decimal constant is unsigned only in ISO C90 [-Werror]
~/dev/osl3/src/liboslexec/gabornoise.cpp:69:28: error: ‘long’ invalid for ‘operator()’
cc1plus: all warnings being treated as errors

this can be fixed by changing line 70 to :

return (m_seed *= 3039177861u) / float(UINT_MAX);

previously it was :
return (m_seed *= 3039177861) / float(UINT_MAX);

@iRi-E
iRi-E commented Nov 2, 2012

I got the same error.

32bit builds failed, but 64bit ones secceeded.

@lgritz
Sony Pictures Imageworks member
lgritz commented Nov 2, 2012

OK, I just pushed a fix for this to the master.
Do you need this backported to a tagged release, or is the master top-of-tree ok?

@lgritz
Sony Pictures Imageworks member
lgritz commented Nov 2, 2012

I'm going to close, assuming this is fine. Just let me know if the fix doesn't work for you, or if you need a backport.

@lgritz lgritz closed this Nov 2, 2012
@iRi-E
iRi-E commented Nov 3, 2012

Thanks, but I encountered another build failure on 32bit system:

[ 67%] Building CXX object liboslexec/CMakeFiles/oslexec.dir/automata.cpp.o
cd /build/buildd/openshadinglanguage-1.2/debian/cmake/liboslexec && /usr/bin/c++ -Doslexec_EXPORTS -DOPENEXR_VERSION=010601 -DUSE_TBB=1 -DOSL_LLVM_VERSION=31 -fno-rtti -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -DNDEBUG -fPIC -I/usr/lib/llvm-3.1/include -I/usr/include/OpenEXR -I/build/buildd/openshadinglanguage-1.2/src/include -I/build/buildd/openshadinglanguage-1.2/debian/cmake/include -I/build/buildd/openshadinglanguage-1.2/src/liboslcomp -I/build/buildd/openshadinglanguage-1.2/debian/cmake/liboslexec -I/build/buildd/openshadinglanguage-1.2/src/liboslexec -Wall -Werror -o CMakeFiles/oslexec.dir/automata.cpp.o -c /build/buildd/openshadinglanguage-1.2/src/liboslexec/automata.cpp
/build/buildd/openshadinglanguage-1.2/src/liboslexec/automata.cpp: In member function 'std::string OSL::NdfAutomata::tostr() const':
/build/buildd/openshadinglanguage-1.2/src/liboslexec/automata.cpp:266:39: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t {aka unsigned int}' [-Werror=format]
/build/buildd/openshadinglanguage-1.2/src/liboslexec/automata.cpp:266:39: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t {aka unsigned int}' [-Werror=format]
/build/buildd/openshadinglanguage-1.2/src/liboslexec/automata.cpp: In member function 'std::string OSL::DfAutomata::tostr() const':
/build/buildd/openshadinglanguage-1.2/src/liboslexec/automata.cpp:414:39: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t {aka unsigned int}' [-Werror=format]
/build/buildd/openshadinglanguage-1.2/src/liboslexec/automata.cpp:414:39: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t {aka unsigned int}' [-Werror=format]

To avoid this error, the format string "%ld" should be replaced with "%zd" or "%zu".

Anyway, I want the fixes to be backported to 1.2 branch.

@lgritz
Sony Pictures Imageworks member
lgritz commented Nov 3, 2012

I think the 'z' modifier is not support by Visual Studio on Windows.
Instead, I've addressed this problem by using Strutil::format(), which in turn uses the type-safe "tinyformat" from Chris Foster. Should solve the problem on all platforms.
See pull request #173

@iRi-E
iRi-E commented Nov 3, 2012

Oops, I was testing my solution only on Ubuntu...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.