主题中讨论的其他器件:HALCOGEN、 TMS570LC4357、 LAUNCHXL2-RM46
我正在使用 HALCoGen 生成的启动代码和链接器文件。 我正在使用 gcc 格式输出。
在 C++中、如果我有一个实例化全局的类、则永远不会调用构造函数。
静态 MyClass myClassObj;
我从未在构造函数中遇到断点,也没有设置成员变量。
我使用 了覆盖构造函数部分中此处概述的一些代码。
https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/
链接器文件已输出.init_array 所需的只是执行此函数。
/* call the coverage initializers if not done by startup code */
void
static_init(
void
) {
void
(**p)(
void
);
extern
uint32_t
__init_array_start, __init_array_end;
/* linker defined symbols, array of function pointers */
uint32_t
beg = (
uint32_t
)&__init_array_start;
uint32_t
end = (
uint32_t
)&__init_array_end;
while
(beg<end) {
p = (
void
(**)(
void
))beg;
/* get function pointer */
(*p)();
/* call constructor */
beg +=
sizeof
(p);
/* next pointer */
}
}
Is the constructor execution supposed to happen automatically in TI code? In the past I've used HALCoGen and I don't recall needing to do this.