Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Rubystuff.org Autobuild
RE: Lot of constructors file [ reply ]  
2008-02-22 10:53
Ruby defines a StringValue macro which conflicts with your code:

#define StringValue(v) rb_string_value(&(v))

By: Jordi p
Lot of constructors file [ reply ]  
2008-02-22 10:01

This seems more a general C++ problem but it only happens compiling the rice file so ...

I have a strange class:

class StringValue
{
/// \brief Copy Constructor
public: StringValue(const StringValue& data);

/// \brief Convert Vector3 to string
public: StringValue(Vector3 data);

/// \brief Convert Vector2<int> to string
public: StringValue(Vector2<int> data);

/// \brief Convert Vector2<double> to string
public: StringValue(Vector2<double> data);

/// \brief Convert Quatern to string
public: StringValue(Quatern data);

And so on

The aim is that giving any data type of the program to this string, it will be automatically transformed when that data type is passed to a method that accepts StringValue (the constructor is automatically called).

I am in fact not interested in wrapping this class, it will not be used by ruby programs.
But I have a more interesting class that uses this, and only because the #include it seems I need to wrap at least the data type. (I'll prefer just not to wrap, if it is possible, this class will be compiled on the same library than the others) So I do this:

Data_Type<StringValue> rb_cStringValue =
define_class<StringValue>("StringValue")
.define_method("Null?", &StringValue::IsNull)
.define_method("Str", &StringValue::GetStr);

And I got the following compilation error (Having define_method or no):

g++ -I. -I../../ -I/usr/lib64/ruby/1.8/x86_64-linux -I/usr/include -I/usr/include/libxml2 -I/usr/local/include -I /usr/local/include/gazebo -I /home/jordi/source/gazebo/server/physics -I /home/jordi/source/gazebo/server/rendering -I /home/jordi/source/gazebo/server -I /home/jordi/source/gazebo/server/sensors -I /usr/include/OGRE -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wall -fPIC -Wall -g -c Model.cc
../../StringValue.hh:51: error: expected identifier before ‘&’ token
../../StringValue.hh:51: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:54: error: expected identifier before ‘&’ token
../../StringValue.hh:54: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:57: error: expected identifier before ‘&’ token
../../StringValue.hh:57: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:60: error: expected identifier before ‘&’ token
../../StringValue.hh:60: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:63: error: expected identifier before ‘&’ token
../../StringValue.hh:63: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:66: error: expected identifier before ‘&’ token
../../StringValue.hh:66: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:69: error: expected identifier before ‘&’ token
../../StringValue.hh:69: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:72: error: expected identifier before ‘&’ token
../../StringValue.hh:72: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:75: error: expected identifier before ‘&’ token
../../StringValue.hh:75: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:78: error: expected identifier before ‘&’ token
../../StringValue.hh:78: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:81: error: expected identifier before ‘&’ token
../../StringValue.hh:81: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:84: error: expected identifier before ‘&’ token
../../StringValue.hh:84: error: ISO C++ forbids declaration of ‘rb_string_value’ with no type
../../StringValue.hh:87: error: expected class-name before ‘(’ token



The line 51 of the file is the first constructor:

public: StringValue(const StringValue& data);