1# C++ support for RT-Thread # 2 3This is the C++ component in RT-Thread RTOS. In order to support C++ language, this component 4implement a basic environment, such as new/delete operators. 5 6Because RT-Thread RTOS is used in embedded system mostly, there are some rules for C++ applications: 7 81. DOES NOT use exception. 92. DOES NOT use Run-Time Type Information (RTTI). 103. Template is discouraged and it easily causes code text large. 114. Static class variables are discouraged. The time and place to call their constructor function could not be precisely controlled and make multi-threaded programming a nightmare. 125. Multiple inheritance is strongly discouraged, as it can cause intolerable confusion. 13 14*NOTE*: The libc (RT_USING_LIBC in rtconfig.h) must be enable. 15 16About GNU GCC compiler 17 18please add following string in your ld link script: 19 20 // in your .text section 21 PROVIDE(__ctors_start__ = .); 22 /* old GCC version uses .ctors */ 23 KEEP(*(SORT(.ctors.*))) 24 KEEP(*(.ctors)) 25 /* new GCC version uses .init_array */ 26 KEEP (*(SORT(.init_array.*))) 27 KEEP (*(.init_array)) 28 PROVIDE(__ctors_end__ = .); 29 30 . = ALIGN(4); 31 32 // as a standalone section if you use ARM target. 33 34 /* The .ARM.exidx section is used for C++ exception handling. */ 35 /* .ARM.exidx is sorted, so has to go in its own output section. */ 36 __exidx_start = .; 37 ARM.exidx : 38 { 39 *(.ARM.exidx* .gnu.linkonce.armexidx.*) 40 41 /* This is used by the startup in order to initialize the .data secion */ 42 _sidata = .; 43 } > CODE 44 __exidx_end = .; 45 46 /* .data section which is used for initialized data */ 47 48 // in your .data section 49 PROVIDE(__dtors_start__ = .); 50 KEEP(*(SORT(.dtors.*))) 51 KEEP(*(.dtors)) 52 PROVIDE(__dtors_end__ = .); 53 54 . = ALIGN(4); 55