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 that when I do make, I get the 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
for 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 I compile the same program using GCC, it works without errors.
See the diff, as Rev 3019 works in GCC and Solaris Compiler: http://dev.exiv2.org/projects/exiv2/repository/revisions/3020/diff?rev=3020&type=sbs
How to ignore multiple declaration error in Solaris Compiler?
I've calculated the diff of the pre-processed output of the .cpp files in r3018 and 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 a comment on this issue to exiv2.org's wiki and provided the patch which worked past the problem.
The essential issue is that the Solaris Studio compilers do not allow multiline macros in C++. The patch I provided elided this because it commented out the entirety of the rcsId declaration.
As best I can determine, the correct declaration in rcsid_int.hpp is as 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 the pre-processed source not containing an rcsId string.