c++ - Macro in GCC works but in Solaris Compiler fails? -
source: svn checkout svn://dev.exiv2.org/svn/trunk (latest rev: 3020)
my platform: fedora 17 64-bit
the following command works:
cmake -dcmake_cxx_flags=-library=stlport4 - dcmake_cxx_compiler=/opt/oracle/solarisstudio12.3/bin/cc - dcmake_c_compiler=/opt/oracle/solarisstudio12.3/bin/cc .
but after when make, error:
scanning dependencies of target exiv2lib [ 17%] building cxx object src/cmakefiles/exiv2lib.dir/asfvideo.cpp.o cd /home/wani/gsoc/exiv2-trunk/trunk/src && /opt/oracle/solarisstudio12.3/bin/cc - dexv_building_lib -dexv_have_dll -dexv_localedir=\"/usr/local/share/locale\" - dexv_have_stdint_h -library=stlport4 -kpic -i/home/wani/gsoc/exiv2-trunk/trunk - i/home/wani/gsoc/exiv2-trunk/trunk/xmpsdk/include -o cmakefiles/exiv2lib.dir/asfvideo.cpp.o -c /home/wani/gsoc/exiv2- trunk/trunk/src/asfvideo.cpp "/home/wani/gsoc/exiv2-trunk/trunk/src/error.cpp", line 29: error: multiple declaration rcsid. 1 error(s) detected.
content of error.cpp:
28 #include "rcsid_int.hpp" 29 exiv2_rcsid("@(#) $id: error.cpp 2681 2012-03-22 15:19:35z ahuggel $")
content of rcsid_int.hpp:
#ifndef rcsid_int_hpp_ #define rcsid_int_hpp_ #if !defined (exiv2_rcsid) #if defined(__clang__) #define exiv2_rcsid(id) #elif defined(os_solaris) #define exiv2_rcsid(id) \ { \ inline const char* getrcsid(const char*) { return id ; } \ const char* rcsid = getrcsid(rcsid); \ } #else #define exiv2_rcsid(id) \ namespace { \ inline const char* getrcsid(const char*) { return id ; } \ const char* rcsid = getrcsid(rcsid); \ } #endif #endif #endif
if compile same program using gcc, works without errors.
see diff, rev 3019 works in gcc , solaris compiler: http://dev.exiv2.org/projects/exiv2/repository/revisions/3020/diff?rev=3020&type=sbs
how ignore multiple declaration error in solaris compiler?
i've calculated diff of pre-processed output of .cpp files in r3018 , r3019:
2a3,6 > #30 "/home/wani/exiv2-trunk/trunk/src/asfvideo.cpp" > namespace { inline const char * getrcsid ( const char * ) { return "@(#) $id$" ; } const char * rcsid = getrcsid ( rcsid > #30 > ) ; }
i posted comment on issue exiv2.org's wiki , provided patch worked past problem.
the essential issue solaris studio compilers not allow multiline macros in c++. patch provided elided because commented out entirety of rcsid declaration.
as best can determine, correct declaration in rcsid_int.hpp follows:
#if defined(__clang__) || (defined(os_solaris) && defined(__sunpro_cc)) #define exiv2_rcsid(id) #else #define exiv2_rcsid(id) \ namespace { \ inline const char* getrcsid(const char*) { return id ; } \ const char* rcsid = getrcsid(rcsid); \ } #endif
this results in pre-processed source not containing rcsid string.
Comments
Post a Comment