Home » Developing U++ » U++ Developers corner » How to determine if U++ is being utilized...
How to determine if U++ is being utilized... [message #53418] |
Thu, 02 April 2020 05:37  |
ptkacz
Messages: 89 Registered: March 2017
|
Member |
|
|
Hi All,
I'm working on a library that will be made use of by a few different applications. For the applications that require a GUI, U++ will be utilized. In cases where no GUI is required, the standard C++ library will be made use of. While a non-GUI application will not require GUI visual elements, where needed, they may for example, still need need to process image data.
When developing code (I.e. classes or functions, etc) that makes use of U++'s framework, there are certain dependencies that will probably be inherited. The library becomes dependant on the U++ framework. If that same class or functions are to be reused outside of the U++ framework, they can't because of certain dependencies they are built around, dependencies no longer available.
Likewise, if code was first designed outside of the U++ framework, and later incorporated into a U++ program, the code would have to place nice in the U++ sandbox.
Is there a way for a library to determine or know if U++ is being made use of?
Peter
|
|
|
|
|
Re: How to determine if U++ is being utilized... [message #53456 is a reply to message #53418] |
Sat, 04 April 2020 02:50   |
ptkacz
Messages: 89 Registered: March 2017
|
Member |
|
|
Thanks Novo, to both your answers. I'm familiar with defining macros and making use of the logic directives (i.e. #if, etc). I was looking for something that could avoid having to manually make a macro definition, or prior inclusion, and then have to always make sure that things are defined or not when hopping from one application (project) to another.
After a little bit more digging on the web, it looks like C++17 has added to it for use with the marco pre-processor, a __has_include() function that checks if a header reference exists. Yesterday after updating my system, I tested out the following:
In TheIDE:
#if __has_include("CtrlLib/CtrlLib.h")
CtrlLayout(*this, "U++ Window title");
#else
CtrlLayout(*this, "U++ not here");
#endif
and even,
In Code::Blocks:
#if __has_include("iostream")
cout << "iostream here." << endl;
#else
cout << "iostream not here" << endl;
#endif
#if __has_include("CtrlLib/CtrlLib.h")
cout << "U++ Window here." << endl;
#else
cout << "U++ not here" << endl;
#endif
__has_include() worked in all circumstances, so it looks like I'll have to be making C++17 for just this one feature.
Some additional information on it can be found here, https://en.cppreference.com/w/cpp/preprocessor/include
Again, thanks for your input!
Peter
|
|
|
Re: How to determine if U++ is being utilized... [message #53458 is a reply to message #53456] |
Sat, 04 April 2020 06:34   |
Novo
Messages: 1430 Registered: December 2006
|
Ultimate Contributor |
|
|
IMHO, you are over-complicating very simple things.
The whole idea of U++ is about turning very complicated things into very simple.
That is the point of U++. And you are trying to solve your problem in a completely opposite way.
Just my two cents.
Regards,
Novo
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 19:04:37 CEST 2025
Total time taken to generate the page: 0.02649 seconds
|