-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