New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ImportC #2270
Add support for ImportC #2270
Conversation
I'm not convinced that we should be fixing this. A good example of why is that you have missed header files. Instead, we should be discussing how to separate dubs build manager from its package manager and build a proper build manager for it that isn't D specific. In the meantime, dflags should work. |
No, just dflags do not work. You must either pass an explicite list of C sourcefiles in dub.json (see forum posts), or use some 'preBuild' command to compile your C code to object files and add them to some other explicite list for the linker. What I need in dub is that C files are just picked up like any other D file as a valid source for the compiler. The C header files are intentionally left out here, because it is bad style to have real functions in a C header. Yes, I know, people are doing such things. It is one of the bad habbits of C. If you want to include a C header, just wrap it into a C file, which is then compiled by the D compiler. See the mentioned example project for wrapp ZSTD header. I strongly recommend to add working support for ImportC ASAP. The cleanups you mentioned can be done later after some working solution is provided now. We are talking about really small changes here. Also the other PR is pretty small. There is no danger to mess up sources with some complicated intermediate solution here. But with the next DMD release we should be able to use ImportC directly and eaily instead of explicite sourceFile lists, cumbersome workarounds and preBuild/Generate hacks. Straight and easy support for using C files in DUB is a must with the next DMD release. I will help a lot when we want to promote D as a suitable language alternative for C/C++ programmers. |
@cschlote i agree with you we should speed up to get ready for the next DMD release |
Compilation of C files is not "preBuild". ImportC means there is no longer a distinction between C files with supporting functions and D files with supporting functions. For example: foo.d
bar.c
This is compiled with |
I know, that you can pass the C files directly to the D compiler. But this is not the usecase here. I'm talking about using C files in DUB projects. And Dub is NOT picking up any C source file in e.g. the default 'source' directory (or anywhere else) of a Dub project. And so it is not passed to the D compiler resulting into the problem of missing symbols. An important point is to also support the C header files. As well as preprecessed intermediate files. I will create usecases for these scenarios and provide a new PR asap. Obviously there is some need for it. |
Perhaps not what you are after, but this commit changes |
Fixes #2269