我如何获得GCC __attribute__((构造函数))OSX下工作? [英] How do I get the GCC __attribute__ ((constructor)) to work under OSX?
本文介绍了我如何获得GCC __attribute__((构造函数))OSX下工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
extern void MyInitFunc(void) __attribute__ ((constructor));
extern void MyTermFunc(void) __attribute__ ((destructor));
void MyInitFunc(void)
{
printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
}
void MyTermFunc(void)
{
}
我把这个.c文件是在主应用程序(而不是库或框架)present。它不会被调用根据海湾合作委员会的文档。我失去了一些重要的东西?这是对雪豹X $ C $ 3.2Ç
I put this in a .c file which is present in the main application (not a library or framework). It doesn't get called as per the GCC docs. Am I missing something important? This is on XCode 3.2 on Snow Leopard.
推荐答案
(一)您的code对我的作品汇编放在X code 3.2雪豹运行。
(a) Your code works for me compiling and running on SnowLeopard in Xcode 3.2.
(二)我不知道,当标准输出是保证已经建立。你之前的主运行code。为什么不能在这里更新一个全局变量,然后打印出来在主,看看你的code奔去。
(b) I'm not sure when stdout is guaranteed to have been set up. You're running code before main. Why not update a global variable here, then print it out in main to see if your code ran.
这篇关于我如何获得GCC __attribute__((构造函数))OSX下工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文