PageRenderTime 37ms CodeModel.GetById 35ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/d/constants/example.i

#
Swig | 32 lines | 13 code | 10 blank | 9 comment | 0 complexity | ee5c48920f03321c9c91ce4e4f7df908 MD5 | raw file
 1/* File : example.i */
 2%module example
 3
 4/* Force the generated D code to use the C constant values rather than
 5   retrieving them at runtime. You can also try disabling the feature and
 6   compare the generated code. */
 7%dmanifestconst;
 8
 9
10/* A few preprocessor macros */
11
12#define    ICONST      42
13#define    FCONST      2.1828
14#define    CCONST      'x'
15#define    CCONST2     '\n'
16#define    SCONST      "Hello World"
17#define    SCONST2     "\"Hello World\""
18
19/* This should work just fine */
20#define    EXPR        ICONST + 3*(FCONST)
21
22/* This shouldn't do anything */
23#define    EXTERN      extern
24
25/* Neither should this (BAR isn't defined) */
26#define    FOO         (ICONST + BAR)
27
28
29/* The following directives also produce constants */
30
31%constant int iconst = 37;
32%constant double fconst = 3.14;