PageRenderTime 84ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/www.cppreference.com/wiki/preprocessor/pragma

https://github.com/tsgates/cclookup
#! | 100 lines | 82 code | 18 blank | 0 comment | 0 complexity | e8595091d4f76c54d1131fd9cb6a87d3 MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
  4. lang="en" dir="ltr">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>preprocessor:pragma</title>
  8. <meta name="generator" content="DokuWiki" />
  9. <meta name="robots" content="index,follow" />
  10. <meta name="date" content="2010-10-28T18:17:02-0700" />
  11. <meta name="keywords" content="preprocessor,pragma" />
  12. <link rel="search" type="application/opensearchdescription+xml" href="http://www.cppreference.com/wiki/lib/exe/opensearch.php" title="C++ Reference" />
  13. <link rel="start" href="../../index.html" />
  14. <link rel="contents" href="http://www.cppreference.com/wiki/preprocessor/pragma?do=index" title="Sitemap" />
  15. <link rel="alternate" type="application/rss+xml" title="Recent Changes" href="http://www.cppreference.com/wiki/feed.php" />
  16. <link rel="alternate" type="application/rss+xml" title="Current Namespace" href="http://www.cppreference.com/wiki/feed.php?mode=list&amp;ns=preprocessor" />
  17. <link rel="alternate" type="text/html" title="Plain HTML" href="http://www.cppreference.com/wiki/_export/xhtml/preprocessor/pragma" />
  18. <link rel="alternate" type="text/plain" title="Wiki Markup" href="http://www.cppreference.com/wiki/_export/raw/preprocessor/pragma" />
  19. <link rel="canonical" href="pragma" />
  20. <link rel="stylesheet" media="screen" type="text/css" href="../lib/exe/css.php@t=custom1&amp;tseed=1289693594" />
  21. <link rel="stylesheet" media="all" type="text/css" href="../lib/exe/css.php@s=all&amp;t=custom1&amp;tseed=1289693594" />
  22. <link rel="stylesheet" media="print" type="text/css" href="../lib/exe/css.php@s=print&amp;t=custom1&amp;tseed=1289693594" />
  23. <script type="text/javascript" ><!--//--><![CDATA[//><!--
  24. var NS='preprocessor';var JSINFO = {"id":"preprocessor:pragma","namespace":"preprocessor"};
  25. //--><!]]></script>
  26. <script type="text/javascript" charset="utf-8" src="../lib/exe/js.php@tseed=1289693594" ></script>
  27. </head>
  28. <body>
  29. <div class="dokuwiki export">
  30. <h2 class="sectionedit1"><a name="pragma" id="pragma">#pragma</a></h2>
  31. <div class="level2">
  32. <pre class="cpp code cpp"> <span class="co2">#pragma lexems</span></pre>
  33. <p>
  34. The #pragma command gives the programmer the ability to tell the compiler to do certain things. Since the #pragma command is implementation specific, uses vary from compiler to compiler. One option might be to trace program execution.
  35. </p>
  36. <p>
  37. Below are some compiler families, the operating system on which they&#039;re found and the pragma directives which are part of that implementation
  38. </p>
  39. <p>
  40. Also pragma is used to allow the programmer to call a function before main is called or after main exits.
  41. </p>
  42. <pre class="cpp code cpp"><span class="co2">#pragma startup fun() //The function must have return void type &amp; no parameters.</span>
  43. <span class="co2">#pragma exit fun1()</span></pre>
  44. </div>
  45. <!-- EDIT1 SECTION "#pragma" [1-656] -->
  46. <h3 class="sectionedit2"><a name="gnu_c_compiler_gcc_-_gnulinux_bsd_gnuhurd_gnudarwinmac_os_x_windows_mingw" id="gnu_c_compiler_gcc_-_gnulinux_bsd_gnuhurd_gnudarwinmac_os_x_windows_mingw">GNU C Compiler (GCC) - GNU/Linux, BSD, GNU/Hurd, GNU/Darwin/Mac OS X, Windows (MinGW)</a></h3>
  47. <div class="level3">
  48. </div>
  49. <h4><a name="redefine_extname" id="redefine_extname">redefine_extname</a></h4>
  50. <div class="level4">
  51. <pre class="cpp code cpp"> <span class="co2">#pragma redefine_extname printf prnt</span></pre>
  52. <p>
  53. Gives C functions a different programmer defined symbol when translated to assembly language.
  54. </p>
  55. </div>
  56. <h4><a name="extern_prefix" id="extern_prefix">extern_prefix</a></h4>
  57. <div class="level4">
  58. <pre class="cpp code cpp"> <span class="co2">#pragma extern_prefix ext_ // begin prefixing</span>
  59. <span class="co1">// your external symbols with the assembly prefix is here</span>
  60. <span class="co2">#pragma extern_prefix // end prefixing</span></pre>
  61. <p>
  62. Prefixes all external function assembly symbols with the string prefix. Another #pragma extern_prefix will end prefixing of externals.
  63. </p>
  64. </div>
  65. <h4><a name="pack" id="pack">pack</a></h4>
  66. <div class="level4">
  67. <pre class="cpp code cpp"> <span class="co2">#pragma pack(64) // optimize all subsequent classes, unions, and structures for 64 bit code</span></pre>
  68. <p>
  69. Packing is an optimization method that makes the members of structures, classes, and unions align to a factor of the packing boundary. This usually makes it easier (thus faster) for the processor to access data since it&#039;s packed to align with what the processor is used to dealing with, however it costs memory by having random unnecessary garbage data inserted to align the code with the pack. the numerical value in parenthesis must be a power of 2 (2, 4, 8, 16, 32, 64.). There are other ways to use pack and they&#039;re described below but above is the simplest and most common way. you can use
  70. </p>
  71. <pre class="cpp code cpp"><span class="co2">#pragma pack() /* with empty parenthesis */</span></pre>
  72. <p>
  73. to reset the packing to the compiler default.
  74. </p>
  75. <p>
  76. #pragma pack(push) and #pragma pack(pop) are on the way, I&#039;m still researching them and their functionality. -/&gt;
  77. This document is still under construction, I intend to continue adding compilers and their pragma options instead of leaving this largely blank. -GinoMan -/&gt;
  78. </p>
  79. </div>
  80. <!-- EDIT2 SECTION "GNU C Compiler (GCC) - GNU/Linux, BSD, GNU/Hurd, GNU/Darwin/Mac OS X, Windows (MinGW)" [657-] --></div>
  81. </body>
  82. </html>