-5
我第一次真正使用#pragma,出于某种原因,我没有得到与在线发布的输出相同的输出,函数不打印出来,我使用GCC v5.3和clang v。3.7。这里的代码#pragma在C中无法正常工作?
#include<stdio.h>
void School();
void College() ;
#pragma startup School 105
#pragma startup College
#pragma exit College
#pragma exit School 105
void main(){
printf("I am in main\n");
}
void School(){
printf("I am in School\n");
}
void College(){
printf("I am in College\n");
}
我用“gcc file.c”和“clang file.c”编译。 我得到的输出是“I am in main”
你在哪里找到的'[GCC文件]中的#pragma startup'和'的#pragma exit'(https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc /Pragmas.html)? –
Pragma依赖于编译器,[GCC在线文档关于pragmas](https://gcc.gnu.org/onlinedocs/gcc/Pragmas.html)没有列出这些,所以它可能是Clang(其目的是为GCC兼容性)也没有它们。 [Visual C编译器没有这些编译指示](https://msdn.microsoft.com/en-us/library/d9x1s805.aspx)。快速搜索似乎表明它们特定于[Embarcadero C++ Builder](https://www.embarcadero.com/products/cbuilder)。 –
http://stackoverflow.com/q/29462376/971127 – BLUEPIXY