Thoughts on C ++ cross-platform development

Source: Internet
Author: User

Why c ++ cross-platform development?

From the two projects I participated in, the underlying libraries are generally required to be cross-platform. The upper UI Layer can adopt the existing cross-platform UI framework or the unique UI framework of the Platform (to better use the platform features)

The C ++ underlying library encapsulates a large number of Io operations, or the APIS required for product development. In this way, code can be reused to reduce the cost of cross-platform development.

In addition, the development and maintenance of core APIs can be well controlled by a single team to better control risks and quality.

Cross-platform

Generally, we use the C ++ STD library, which is developed by the International c ++ Standards Committee. It should be supported by all compilers.

However, when we encounter some libraries and functions that are unique to compilers on some Linux and Windows platforms, we need to treat them differently.

1. Many people use macros to control related tasks.Code. However, when there are a lot of platform differences, the code is very messy, and macros are everywhere, so you will lose your appetite.

2. To avoid the above problems, we can separate platform differences and use them as two sets of implementation files. Then, the precompiled macro is used to control which header file to reference. This looks much clearer.

3. Recently, in a new project, we found a cross-platform tool cmake. We can directly reference related files for related platforms in cmake. Let macros take effect when generating related projects.

This makes it clearer.

4. cross-platform lib can be used. For example, boost and QT are cross-platform. It is very convenient to use. Qt not only writes a large number of C ++ libraries, but also its UI framework is cross-platform. Therefore, it is widely used in cross-platform UI development.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.