Search code examples
cgccpragma

How to write pragmas in C


I know that #pragmas are compiler directives which are used to provide additional information to the compiler. My question is that, I need to write some #pragmas for my project. i.e, I need to invoke some particular code when there are some particular pattern in code. Can some one throw light on this?


Solution

  • You can't write your own #pragmas. You must look into your compiler's handbook for which #pragmas are supported.

    Alternatively, if your compiler allows you to modify its source code (license- and sourcecode-wise), you might hack some new ones in. Don't expect it to be a trivial task, there's usually no enduser-friendly plug-in write-your-own-pragmas system.