> Ideas are very welcome.
Don't name a constant "VERSION"?  I know it might not sound very satisfying,
but this is not really a problem with Thrift.h.  Any macro defined by any
file you include before cassandra_constants can conflict with a symbol used
in that file.

That said, I think there might be a way to configure autoheader to use
a symbol like THRIFT_VERSION instead of just VERSION.  I'm not sure what
it is, though.

--David

On 08/27/2010 09:55 AM, Mina Naguib wrote:
> 
> Hi folks
> 
> I'm running into a peculiar issue with compiling the code outputted by the 
> thrift CPP generator.
> 
> Currently using thrift 0.4 against the cassandra 0.6.4 interface file, but I 
> believe the problem isn't related to a particular version of either (or 
> cassandra at all).
> 
> Once the thrift generator is run, the following compiles nicely:
> $ g++ -I/usr/local/thrift_04/include/thrift -I/opt/local/include -c 
> gen-cpp/cassandra_constants.cpp -o gen-cpp/cassandra_constants.o
> 
> However, I'm working on a piece of software (libcassandra) which itself uses 
> autotools.  That means the compile line is very large, however the breakage 
> happens specifically when -DHAVE_CONFIG_H is added:
> 
> $ g++ -DHAVE_CONFIG_H -I/usr/local/thrift_04/include/thrift 
> -I/opt/local/include -c gen-cpp/cassandra_constants.cpp -o 
> gen-cpp/cassandra_constants.o
> In file included from gen-cpp/cassandra_constants.cpp:6:
> gen-cpp/cassandra_constants.h:17: error: expected unqualified-id before 
> string constant
> gen-cpp/cassandra_constants.cpp: In constructor 
> ‘org::apache::cassandra::cassandraConstants::cassandraConstants()’:
> gen-cpp/cassandra_constants.cpp:13: error: assignment of read-only location
> gen-cpp/cassandra_constants.cpp:13: error: invalid array assignment
> 
> The offending line is gen-cpp/cassandra_constants.h:17:
>   std::string VERSION;
> 
> It's syntactically correct, however:
>  * That file includes gen-cpp/cassandra_types.h
>  * Which includes Thrift.h
>  * Which, if HAVE_CONFIG is defined, includes config.h
>  * which does: #define VERSION "0.4.0"
> 
> The end result is that the defined VERSION is substituted, causing the 
> generated code to actually be syntactically invalid:
>   std::string "0.4.0";
> 
> To work-around the issue, I've edited gen-cpp/cassandra_constants.h, and 
> removed its include of gen-cpp/cassandra_types.h, which lead to requiring 
> include <strong>.  I suppose another option is to #undef VERSION
> 
> Once that was done, the rest of the files compiled nicely, and the final 
> library and program ran well.
> 
> It's inevitably a hack though, as the next time the code is re-generated from 
> the interface the same manual editing would need to be done.  I'm also unsure 
> if this is a bug per-se, or I'm doing something completely wrong w.r.t. my 
> use of autotools in libcassandra.  Ideas are very welcome.

Reply via email to