tango-controls / cppTango

Moved to gitlab
http://tango-controls.org
41 stars 34 forks source link

cpp_test_suite/event/event_lock.cpp: Make it compile on 32-bit linux #803

Closed t-b closed 3 years ago

t-b commented 3 years ago

The following compile error with gcc 8.3 is generated:

/home/firma/devel/cppTango/cpp_test_suite/event/event_lock.cpp: In function ‘void set_abs_change(std::cxx11::string, std::cxx11::string)’: /home/firma/devel/cppTango/cpp_test_suite/event/event_lock.cpp:51:21: error: ambiguous overload for ‘operator<<’ (operand types are ‘Tango::DbDatum’ a nd ‘unsigned int’) attribute_datum << 1u;


In file included from /home/firma/devel/cppTango/cppapi/server/tango.h:97,
                 from /home/firma/devel/cppTango/cpp_test_suite/event/event_lock.cpp:17:
/home/firma/devel/cppTango/cppapi/client/dbapi.h:528:7: note: candidate: ‘void Tango::DbDatum::operator<<(bool)’
  void operator << (bool val);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:637:7: note: candidate: ‘void Tango::DbDatum::operator<<(short int)’
  void operator << (short);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:638:7: note: candidate: ‘void Tango::DbDatum::operator<<(unsigned char)’
  void operator << (unsigned char);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:639:7: note: candidate: ‘void Tango::DbDatum::operator<<(short unsigned int)’
  void operator << (unsigned short);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:640:7: note: candidate: ‘void Tango::DbDatum::operator<<(Tango::DevLong)’
  void operator << (DevLong);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:641:7: note: candidate: ‘void Tango::DbDatum::operator<<(Tango::DevULong)’
  void operator << (DevULong);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:642:7: note: candidate: ‘void Tango::DbDatum::operator<<(Tango::DevLong64)’
  void operator << (DevLong64);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:643:7: note: candidate: ‘void Tango::DbDatum::operator<<(Tango::DevULong64)’
  void operator << (DevULong64);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:644:7: note: candidate: ‘void Tango::DbDatum::operator<<(float)’
  void operator << (float);
       ^~~~~~~~
/home/firma/devel/cppTango/cppapi/client/dbapi.h:645:7: note: candidate: ‘void Tango::DbDatum::operator<<(double)’
  void operator << (double);

By making the fed in variable unsigned long we avoid the error.
t-b commented 3 years ago

That code does not exist in 9.3-backports.

t-b commented 3 years ago

@mliszcz @bourtemb Could you have a look. This is too trivial to be kept around open for the migration.

mliszcz commented 3 years ago

Maybe we should have just six overloads for std::{u,}int{16,32,64}_t instead of trying to figure out which one is which on each platform. But this is a topic for separate discussion I guess.

bourtemb commented 3 years ago

In theory, users should use only the Tango types because you never know how it can be converted in a Tango Database. For the moment, everything is converted as string in the DataBase but there is no guarantee this will stay like this in future versions or Database server alternatives.