Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » U++ does not appear to like playing nice with the Boost algorithm string library?
U++ does not appear to like playing nice with the Boost algorithm string library? [message #53457] Sat, 04 April 2020 03:07 Go to next message
ptkacz is currently offline  ptkacz
Messages: 89
Registered: March 2017
Member
When I compile the following (console application) code in U++:
#include <iostream>
#include <string>
#include <iostream>
using namespace std;

#include <Core/Core.h>
using namespace Upp;

#include <boost/algorithm/string.hpp>

CONSOLE_APP_MAIN
{
    std::string str = "   Lots of filler space   ";
    boost::algorithm::trim(str);
    std::cout<<"\""<< str <<"\""<<std::endl;
}

the following error is resulting:
----- Core ( GCC DEBUG SHARED DEBUG_FULL BLITZ POSIX LINUX ) (1 / 2)
----- BoostStringTest ( MAIN GCC DEBUG SHARED DEBUG_FULL BLITZ POSIX LINUX ) (2 / 2)
BoostStringTest.cpp
In file included from /home/ptkacz/upp/uppsrc/Core/i18n.h:17:0,
                 from /home/ptkacz/upp/uppsrc/Core/Core.h:337,
                 from /home/ptkacz/MyApps/BoostStringTest/BoostStringTest.cpp:6:
/usr/include/boost/core/ref.hpp: In constructor 'boost::reference_wrapper<T>::reference_wrapper(T&)':
/home/ptkacz/upp/uppsrc/Core/t_.h:9:24: error: class 'boost::reference_wrapper<T>' does not have any field named 't_GetLngString'
 #define t_(x)          t_GetLngString(x)
                        ^
BoostStringTest: 1 file(s) built in (0:01.55), 1551 msecs / file, duration = 1551 msecs

There were errors. (0:01.55)

I do know that U++ has it's only string utility functions, but was attempting to make use of code brought in from another application that I'm working on. Independently of any existing code, I wrote a simple C++ application in Code::Blocks, the code compiles and runs as expected.


Peter
Re: U++ does not appear to like playing nice with the Boost algorithm string library? [message #53460 is a reply to message #53457] Sat, 04 April 2020 10:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
ptkacz wrote on Sat, 04 April 2020 03:07
When I compile the following (console application) code in U++:
#include <iostream>
#include <string>
#include <iostream>
using namespace std;

#include <Core/Core.h>
using namespace Upp;

#include <boost/algorithm/string.hpp>

CONSOLE_APP_MAIN
{
    std::string str = "   Lots of filler space   ";
    boost::algorithm::trim(str);
    std::cout<<"\""<< str <<"\""<<std::endl;
}

the following error is resulting:
----- Core ( GCC DEBUG SHARED DEBUG_FULL BLITZ POSIX LINUX ) (1 / 2)
----- BoostStringTest ( MAIN GCC DEBUG SHARED DEBUG_FULL BLITZ POSIX LINUX ) (2 / 2)
BoostStringTest.cpp
In file included from /home/ptkacz/upp/uppsrc/Core/i18n.h:17:0,
                 from /home/ptkacz/upp/uppsrc/Core/Core.h:337,
                 from /home/ptkacz/MyApps/BoostStringTest/BoostStringTest.cpp:6:
/usr/include/boost/core/ref.hpp: In constructor 'boost::reference_wrapper<T>::reference_wrapper(T&)':
/home/ptkacz/upp/uppsrc/Core/t_.h:9:24: error: class 'boost::reference_wrapper<T>' does not have any field named 't_GetLngString'
 #define t_(x)          t_GetLngString(x)
                        ^
BoostStringTest: 1 file(s) built in (0:01.55), 1551 msecs / file, duration = 1551 msecs

There were errors. (0:01.55)

I do know that U++ has it's only string utility functions, but was attempting to make use of code brought in from another application that I'm working on. Independently of any existing code, I wrote a simple C++ application in Code::Blocks, the code compiles and runs as expected.


Peter


Well, this looks like simple nameclash. Try

#undef t_

after #include <Core/Core.h>.

t_ is used to designate localized strings that are subject to language translation.

Maybe it does not have to be macro, then this would be solved by namespaces. Will try...

Mirek
Re: U++ does not appear to like playing nice with the Boost algorithm string library? [message #53467 is a reply to message #53457] Sat, 04 April 2020 19:51 Go to previous messageGo to next message
ptkacz is currently offline  ptkacz
Messages: 89
Registered: March 2017
Member
Thanks Mirek, I just tried that and it worked! To get around that issue, I did update my code to make use of the trim ends function that U++ has available. I do think undefining things is probably not a recommended solution, I couldn't possibly think of what else could go wrong.

Re: U++ does not appear to like playing nice with the Boost algorithm string library? [message #53472 is a reply to message #53467] Sun, 05 April 2020 10:15 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
ptkacz wrote on Sat, 04 April 2020 19:51
Thanks Mirek, I just tried that and it worked! To get around that issue, I did update my code to make use of the trim ends function that U++ has available. I do think undefining things is probably not a recommended solution, I couldn't possibly think of what else could go wrong.



I have actually replaced that macro with inline function in the trunk, so very likely it will work without that #undef witht the trunk for now.

(That said, I am not yet sure whether this change is OK, it is possible I will be forced to remove yet to maintain compatibility).

Mirek
Previous Topic: How to determine if U++ is being utilized...
Next Topic: Things we want from Linux/FreeBSD release archives
Goto Forum:
  


Current Time: Thu Mar 28 13:08:29 CET 2024

Total time taken to generate the page: 0.00955 seconds