PageRenderTime 178ms CodeModel.GetById 31ms RepoModel.GetById 20ms app.codeStats 0ms

/trunk/Examples/go/constants/index.html

#
HTML | 55 lines | 44 code | 11 blank | 0 comment | 0 complexity | e4fa21572e2b31b67e2d9d848fb07d69 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:go:constants</title>
  4. </head>
  5. <body bgcolor="#ffffff">
  6. <tt>SWIG/Examples/go/constants/</tt>
  7. <hr>
  8. <H2>Wrapping C Constants</H2>
  9. <p>
  10. When SWIG encounters C preprocessor macros and C declarations that
  11. look like constants, it creates a Go constant with an identical value.
  12. Click <a href="example.i">here</a> to see a SWIG interface with some
  13. constant declarations in it.
  14. <h2>Accessing Constants from Go</h2>
  15. Click <a href="../../../Doc/Manual/Go.html#go_constants">here</a> for
  16. the section on constants in the SWIG and Go documentation.
  17. <p>
  18. Click <a href="runme.go">here</a> to see a Go program that prints out
  19. the values of the constants contained in the above file.</p>
  20. <h2>Key points</h2>
  21. <ul>
  22. <li>All names are capitalized to make them visible.
  23. <li>The values of preprocessor macros are converted into Go constants.
  24. <li>C string literals such as "Hello World" are converted into Go strings.
  25. <li>Macros that are not fully defined are simply ignored. For example:
  26. <blockquote>
  27. <pre>
  28. #define EXTERN extern
  29. </pre>
  30. </blockquote>
  31. is ignored because SWIG has no idea what type of variable this would be.
  32. <p>
  33. <li>Expressions are allowed provided that all of their components are
  34. defined. Otherwise, the constant is ignored.
  35. <li>Certain C declarations involving 'const' are also turned into Go
  36. constants.
  37. <li>The constants that appear in a SWIG interface file do not have to
  38. appear in any sort of matching C source file since the creation of a
  39. constant does not require linkage to a stored value (i.e., a value
  40. held in a C global variable or memory location).
  41. </ul>
  42. <hr>
  43. </body>
  44. </html>