Logging integer value in ArEventLog C++

Hi,

I am trying to log an integer value in C++ using the ArEventLog. However, I encounter some errors using the library in the way I use in desktop C++. I was wondering if we are able to use classes like std::ostringstream in PLC C++?

I get errors when using the statement “std::ostringstream os;” . Are there other ways to convert an integer to a string?

Regards,
Kenneth

Hi,

I don’t think so, check this help page, especially “input/output”, to see which functions are available.

2f6fba92-855a-4de6-aab8-8326a8bfa61b

As for your issue: If you post your code probably someone can point you in the right direction + Automation Runtime programming is faaaaaaar from Desktop programming :laughing:

Best regards!

Thanks, it seems like sstream is supported, but I am having some issues with the code:

int inValue;
std::ostringstream os;
os<<inValue;

I get the error “Error : multiple definition of `strtod’”.

Thanks, it seems like sstream is supported

yes, is fully supported

https://help.br-automation.com/#/en/6/programming%2Fprograms%2Fansic%2Fapplicabilitycppstd%2Fprogrammingmodel_programs_ansic_applicabilitycppstd_inandoutputstringstreams.html

I get the error “Error : multiple definition of `strtod’”.

This is most likely you use the _DEFAULT_INCLUDES and use the asstring library.

//#ifdef _DEFAULT_INCLUDES
// #include <AsDefault.h>
//#endif

1 Like

I am using the ostringstream class in a file that include ArEventLog.h . Currently get this issue without including AsDefault.h

Found a link on Stack Overflow on int to string conversion alternatives:

c++ - How can I convert an int to a string in C++11 without using to_string or stoi? - Stack Overflow

The convert_int_to_string solution works.

2 Likes