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]|
Per GCC's documentation on pragma,
The
#pragmadirective 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With