Add-Ons & Services

Poco::format error

Please post support and help requests here.
Posts: 40
Joined: 14 Jan 2013, 17:15
Location: Italy

Poco::format error

Postby dbarzo » 03 Jun 2014, 15:12

I'm using POCO (v 1.4.6p4) logging framework but I have some problem on formatting strings:

Code: Select all

int MyClass::MyMethod(unsigned short number) { 
  Logger::get("MyLog").information(Poco::format("Log a number [%u]", number));

Here I get:

Log a number [ERRFMT]

And a Poco::BadCastException is thrown.
Digging into the source I noted that the exception is thrown into the Any class:

Code: Select all

template <typename ValueType>
ValueType AnyCast(const Any& operand)
  /// AnyCast operator used to extract a copy of the ValueType from an const Any&.
  /// Example Usage:
  ///     MyType tmp = AnyCast<MyType>(anAny).
  /// Will throw a BadCastException if the cast fails.
  /// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ...
  /// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
  /// these cases.
    ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
    if (!result) throw BadCastException("Failed to convert between const Any types");
    return *result;

Could someone tell me where I wrong?
Thanks in advance.

Posts: 40
Joined: 14 Jan 2013, 17:15
Location: Italy

Re: Poco::format error

Postby dbarzo » 04 Jun 2014, 09:02

Alex has answered me here on StackOverflow

Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests