1# C++ Support 2 3## Basic Concepts 4 5As 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. 6 7## Working Principles 8 9The compiler supports C++ code identification. The system calls the constructors of global objects to perform initialization operations. 10 11## Development Guidelines 12 13### Available APIs 14 15**Table 1** APIs supported by C++ 16 17<a name="table14277123518139"></a> 18<table><thead align="left"><tr id="row152771935131315"><th class="cellrowborder" valign="top" width="23.792379237923793%" id="mcps1.2.4.1.1"><p id="p1127733591316"><a name="p1127733591316"></a><a name="p1127733591316"></a>Function</p> 19</th> 20<th class="cellrowborder" valign="top" width="33.02330233023302%" id="mcps1.2.4.1.2"><p id="p22771357138"><a name="p22771357138"></a><a name="p22771357138"></a>API</p> 21</th> 22<th class="cellrowborder" valign="top" width="43.18431843184319%" id="mcps1.2.4.1.3"><p id="p327714358130"><a name="p327714358130"></a><a name="p327714358130"></a>Description</p> 23</th> 24</tr> 25</thead> 26<tbody><tr id="row119525513581"><td class="cellrowborder" valign="top" width="23.792379237923793%" headers="mcps1.2.4.1.1 "><p id="p2099535514346"><a name="p2099535514346"></a><a name="p2099535514346"></a>Prerequisites for using C++ features</p> 27</td> 28<td class="cellrowborder" valign="top" width="33.02330233023302%" headers="mcps1.2.4.1.2 "><p id="p3155620345"><a name="p3155620345"></a><a name="p3155620345"></a>LOS_CppSystemInit</p> 29</td> 30<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.3 "><p id="p4616566343"><a name="p4616566343"></a><a name="p4616566343"></a>Initializes C++ constructors.</p> 31</td> 32</tr> 33</tbody> 34</table> 35 36### How to Develop 37 38Before 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\_\_**. 39 40**Table 2** Parameter description 41 42<a name="table71191652173718"></a> 43<table><thead align="left"><tr id="row1512085253715"><th class="cellrowborder" valign="top" width="42.77%" id="mcps1.2.3.1.1"><p id="p16120175233720"><a name="p16120175233720"></a><a name="p16120175233720"></a>Parameter</p> 44</th> 45<th class="cellrowborder" valign="top" width="57.230000000000004%" id="mcps1.2.3.1.2"><p id="p61205526372"><a name="p61205526372"></a><a name="p61205526372"></a>Description</p> 46</th> 47</tr> 48</thead> 49<tbody><tr id="row11120135213714"><td class="cellrowborder" valign="top" width="42.77%" headers="mcps1.2.3.1.1 "><p id="p1053212673917"><a name="p1053212673917"></a><a name="p1053212673917"></a>__init_array_start__</p> 50</td> 51<td class="cellrowborder" valign="top" width="57.230000000000004%" headers="mcps1.2.3.1.2 "><p id="p2208154219392"><a name="p2208154219392"></a><a name="p2208154219392"></a>Start of the <strong id="b13329113893818"><a name="b13329113893818"></a><a name="b13329113893818"></a>init_array</strong> section</p> 52</td> 53</tr> 54<tr id="row1591908143918"><td class="cellrowborder" valign="top" width="42.77%" headers="mcps1.2.3.1.1 "><p id="p491968193914"><a name="p491968193914"></a><a name="p491968193914"></a>__init_array_end__</p> 55</td> 56<td class="cellrowborder" valign="top" width="57.230000000000004%" headers="mcps1.2.3.1.2 "><p id="p6919189393"><a name="p6919189393"></a><a name="p6919189393"></a>End of the <strong id="b48960753912"><a name="b48960753912"></a><a name="b48960753912"></a>init_array</strong> section</p> 57</td> 58</tr> 59</tbody> 60</table> 61 62>![](../public_sys-resources/icon-note.gif) **NOTE:** 63>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. 64 65### Development Example 66 67``` 68void app_init(void) 69{ 70...... 71/* Initialize C++ in the startup phase. */ 72LOS_CppSystemInit((UINTPTR)&__init_array_start__, (UINTPTR)&__init_array_end__); 73/* C++ service */ 74...... 75} 76``` 77 78