1.

What are pragma directives?

Answer»

This is a special-purpose directive that is used to enable or disable certain functionality. This type of directive is COMPILER-specific, meaning it differs from one compiler to the next. The following are some of the #pragma directives:

  • #pragma startup and #pragma EXIT: These directives help us describe the routines that must run before the program starts (before control transfers to main()) and right before programme exit (just before control returns from main()).
  • #pragma warn Directive: This directive is used to hide warning messages that appear during the compilation process. When we have a huge programme and want to solve all of the errors before looking at warnings, we may use this to hide all warnings and focus on the faults. By making little syntax adjustments, we may make the warnings visible once more.
  • #pragma GCC poison: The GCC compiler supports this directive, which is used to totally eliminate an identifier from a programme. The #pragma GCC poison directive can be used to prevent an identifier from being used.
  • #pragma GCC dependence: You can use the #pragma GCC dependency to compare the relative dates of two files. A warning is issued if the other file is more recent than the current file. If the current file is derived from the other file and needs to be regenerated, this is handy.
  • #pragma GCC system_header: This pragma does not accept any arguments. The rest of the code in the current file is PROCESSED as though it originated from a system header as a result of this.
  • #pragma once: The #pragma once directive has a fairly STRAIGHTFORWARD concept. Even if the programmer includes it numerous times during a compilation, the header file containing this directive is only included once. There is no mention of this in any ISO C++ standard. The #include guard idiom is comparable to this directive. The use of #pragma only once prevents the programme from being optimised for numerous INCLUSIONS.


Discussion

No Comment Found