Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the GCC Compiler not Support #pragma startup and #pragma exit directives?

I am a rookie in C language and was trying to learn the #pragma preprocessor directive. I looked up on Google and found this link: GeeksforGeeks Pragma Directive in C

In this link, they said that the #pragma startup and the #pragma exit Directives don't work in the GCC compiler. Why is it so??

I wrote the same program as given using the MinGW GCC compiler and it said the following warning:

warning: ignoring #pragma startup func1 [-Wunknown-pragmas]|

warning: ignoring #pragma exit func2 [-Wunknown-pragmas]|

like image 934
Tejinder Singh Hunjan Avatar asked Oct 30 '25 05:10

Tejinder Singh Hunjan


1 Answers

Per GCC's documentation on pragma,

The #pragma directive is the method specified by the C standard for providing additional information to the compiler, beyond what is conveyed in the language itself. . . . A C compiler is free to attach any meaning it likes to other pragmas."

Neither of the directives you mention are defined by the C standard, so there is no reason to expect that they would work on different compilers. As mentioned in the article you linked, GCC chooses to use a different vector-specific feature for communicating that a function should be called before or after main, namely function attributes.

like image 79
Brian Avatar answered Oct 31 '25 21:10

Brian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!