来源: svn checkout svn://dev.exiv2.org/svn/trunk (最新版本: 3020)
我的平台: Fedora 17 64位
以下命令起作用:
cmake -DCMAKE_CXX_FLAGS=-library=stlport4 -
DCMAKE_CXX_COMPILER=/opt/oracle/solarisstudio12.3/bin/CC -
DCMAKE_C_COMPILER=/opt/oracle/solarisstudio12.3/bin/cc .但在那之后,当我真的犯了错误时,我得到了错误:
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.Error.cpp的内容:
28 #include "rcsid_int.hpp"
29 EXIV2_RCSID("@(#) $Id: error.cpp 2681 2012-03-22 15:19:35Z ahuggel $")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如果我用GCC编译相同的程序,它可以正常工作。
请参阅不同之处,因为Rev3019可以在GCC和Solaris编译器中工作:http://dev.exiv2.org/projects/exiv2/repository/revisions/3020/diff?rev=3020&type=sbs
如何在Solaris编译器中忽略多个声明错误?
我已经计算了r3018和r3019中.cpp文件的预处理输出的差异:
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
> ) ; } 发布于 2013-04-19 20:18:24
我在exiv2.org的wiki上发表了关于这个问题的评论,并提供了解决这个问题的补丁。
关键问题是Solaris Studio编译器不允许在C++中使用多行宏。我提供的修补程序省略了这一点,因为它注释掉了整个rcsId声明。
据我所知,rcsid_int.hpp中的正确声明如下:
#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这会导致预处理后的源不包含rcsId字符串。
https://stackoverflow.com/questions/16081514
复制相似问题