PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/perl5/constants/index.html

#
HTML | 53 lines | 39 code | 14 blank | 0 comment | 0 complexity | 341fb8eacd9bdce04e6ba6d7d8966724 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. <html>
  2. <head>
  3. <title>SWIG:Examples:perl5:constants</title>
  4. </head>
  5. <body bgcolor="#ffffff">
  6. <tt>SWIG/Examples/perl5/constants/</tt>
  7. <hr>
  8. <H2>Wrapping C Constants</H2>
  9. <p>
  10. When SWIG encounters C preprocessor macros and C declarations that look like constants,
  11. it creates Perl5 variables with an identical value. Click <a href="example.i">here</a>
  12. to see a SWIG interface with some constant declarations in it.
  13. <h2>Accessing Constants from Perl</h2>
  14. Click <a href="runme.pl">here</a> to see a script that prints out the values
  15. of the constants contained in the above file.
  16. <h2>Key points</h2>
  17. <ul>
  18. <li>The values of preprocessor macros are converted into Perl constants.
  19. <li>Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
  20. <li>Character constants such as 'x' are converted into Perl strings.
  21. <li>C string literals such as "Hello World" are converted into Perl strings.
  22. <li>Macros that are not fully defined are simply ignored. For example:
  23. <blockquote>
  24. <pre>
  25. #define EXTERN extern
  26. </pre>
  27. </blockquote>
  28. is ignored because SWIG has no idea what type of variable this would be.
  29. <p>
  30. <li>Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
  31. <li>Certain C declarations involving 'const' are also turned into Perl constants.
  32. <p>
  33. <li>The constants that appear in a SWIG interface file do not have to appear in any sort
  34. of matching C source file since the creation of a constant does not require linkage
  35. to a stored value (i.e., a value held in a C global variable or memory location).
  36. </ul>
  37. <hr>
  38. </body>
  39. </html>