File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,33 @@ dmd hello.c)
120120 `.h`, or `.c`, compile `hello` with ImportC.
121121 )
122122
123+ $(P A C file that is imported through a package and gets compiled needs
124+ to have a module declaration that includes that package. It is done by giving it a
125+ label as an importC module using the __module keyword guarded by __IMPORTC__ macro.)
126+
127+ $(P In C file living in project/net/hi.c)
128+ ---
129+ #if __IMPORTC__
130+ __module net.hi
131+ #endif
132+
133+ int sqrt(int x) { return x * x; }
134+ ---
135+
136+ $(P D file in project/hello.d)
137+ ---
138+ import net.hi; // C file you need in your D source
139+
140+ void main()
141+ {
142+ assert(sqrt(3) == 9);
143+ }
144+ ---
145+
146+ $(CONSOLE
147+ user@ -- project % dmd hello.d net/hi.c
148+ )
149+
123150$(H2 $(LNAME2 preprocessor, Preprocessor))
124151
125152 $(P ImportC does not have a preprocessor. It is designed to compile C
You can’t perform that action at this time.
0 commit comments