Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Is there a correct way to handle APIs that invent their own types?

For example, WinAPI, QT, Boost.

Many frameworks have their own integer and boolean types, along with more complicated data-types.

So, is it better to use native C/C++ type like bool or alternatives like QBool/BOOL/etc., and native container types like std::map/std::set/std::vector vs reinvented ones like QList/boost::something/ATL::map/etc.

And how do those choices respond to cross platform portability.

TL;DR

Which one QBool IsInteresting(const QString &str) vs bool IsInteresting(const std::string &str)?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Frameworks that have their own replacements for standard library types usually do so because they are also compatible with platforms that do not have a good standard library implementation (such as phones and other embedded systems).

Boost is a special case - it is often practically considered part of the standard library, and several of the highly-used boost libraries were considered for C++0x (some made it, e.g. shared_ptr). Where possible and useful boost is compatible with the C++ standard (library) types.

If you are going to use the same framework for all your product releases and it covers the majority of your needed functionality, it is probably a good idea to save yourself the headache and use the framework's types. That way you don't have to convert back and forth all the time.

If you are going to use multiple GUI frameworks (e.g.if you are targeting multiple platforms not all supported) or if you are using multiple third-party libraries with incompatible types things get more complicated, and you'll have to put some thought into whichever solution has the lowest total impact for your particular project.

share|improve this answer

Always use Standard containers and types where possible. Reinvented containers and types only exist because the libraries in question pre-date Standardisation.

share|improve this answer
1  
Qt doesn't predate standardization. Yet, they have QBool. –  Coder Aug 11 '11 at 9:27
2  
Initial Qt development was somewhere around 1998, i.e. at the same time the first c++ standard was released. But since the uptake of standard features in the compilers was slow, and QOI - especially in regard to the stl - was low, qt needed their own types. –  Fabio Fracassi Aug 11 '11 at 10:17
1  
@Coder: Qt dates back to 1991, several years before the current C++ standard. –  Mike Seymour Aug 11 '11 at 10:21
    
Even Wikipedia says that their first release was 1992. –  DeadMG Aug 11 '11 at 11:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.