C++ Support
Basic Concepts
As one of the most widely used programming languages, C++ supports features, such as classes, encapsulation, and overloading. It is an object-oriented programming language developed based on the C language.
Working Principles
The compiler supports C++ code identification. The system calls the constructors of global objects to perform initialization operations.
Development Guidelines
Available APIs
Table 1 APIs supported by C++
How to Develop
Before using C++ features, you need to call LOS_CppSystemInit to initialize C++ constructors. The initialized constructors are stored in the init_array section, and the section range is passed by the variables __init_array_start__ and __init_array_end__.
Table 2 Parameter description
NOTE: The LOS_CppSystemInit function must be called before a C++ service. When the C library used by the third-party compiler is not musl libc, some classes or APIs (such as std::thread and std::mutex) that are closely related to system resources have compatibility issues and are not recommended to use.
Development Example
void app_init(void)
{
......
/* Initialize C++ in the startup phase. */
LOS_CppSystemInit((UINTPTR)&__init_array_start__, (UINTPTR)&__init_array_end__);
/* C++ service */
......
}