3 ms·
This article is about using the D compiler's ability to import vanilla C code to compile entire C projects.
by WalterBright 4y ago
This article is about using the D compiler's ability to import vanilla C code to compile entire C projects.
- tristanbvk 4y agoThis might actually make my life a lot easier compared to how I am currently doing certain things with some of my libraries that need to interoperate with C. Going to give ImportC a spin there!
- melony 4y agoCan DMD compile C projects directly similar to the Zig compiler?
- WalterBright 4y agoI haven't used Zig, but DMD can compile C projects directly using makefiles or by simply putting the .c files on the dmd command line.
- cxr 4y agoDo you plan on giving Zig a try? (They seem to be doing a lot right.) Taking the opportunity here to point people to "Adding Modules to C in 10 Lines of Code" from NWCPP earlier this year: <https://www.youtube.com/watch?v=2ImfbGm0fls https://www.youtube.com/watch?v=2ImfbGm0fls> (The pitfalls you mention running into there wrt to different compiler instances is itself a decent case study in not relying on singletons <http://www.object-oriented-security.org/lets-argue/singletons http://www.object-oriented-security.org/lets-argue/singleton...>—even if it ultimately wasn't so inconvenient that the work never got done, it would be even more convenient if it didn't need to have been done in the first place!)
- simplotek 4y ago> Do you plan on giving Zig a try? (They seem to be doing a lot right.) All this Zig spam is getting very tiring.
- klodolph 4y agoIn a conversation about languages with this kind of C interop, how can you omit Zig?
- simplotek 4y ago> In a conversation about languages with this kind of C interop It's not. It's a discussion about "the C compiler built into the Digital Mars D compiler". Please stop with all the Zig spam.
- primeblue 4y ago
- pverghese 4y agoInstead of being petulant about it, you could ignore it and move on
- 10241024 4y agoHard to ignore it when it's always in your face: https://news.ycombinator.com/item?id=33331549 https://news.ycombinator.com/item?id=33331549 I don't mind languages getting hyped but seeing posts every week on the front page of HN about an unstable esoteric language with 0 adoption - yes, it's getting tiring.
- pverghese 4y agoHow come it's always accounts made a few days ago which seem too have this problem with other people's interests
- 10241024 4y agoLiterally from the thread I shared: - https://news.ycombinator.com/item?id=33337381 https://news.ycombinator.com/item?id=33337381 (posted from a 12-year-old account) - https://news.ycombinator.com/item?id=33333904 https://news.ycombinator.com/item?id=33333904 (posted from a 2-year-old account)
- melony 4y agoZig can be used as a standalone CC replacement and not just for FFI purposes.
- benreesman 4y agoA lot of people might not know that before doing the D language, Walter was already a world-wide acknowledged expert on the compilation of C and C++. I don’t use D seriously but I’d still bet my ass that something smart happens when you feed C code to the D compiler toolchain.
- krylon 4y ago> A lot of people might not know that Personally, that would surprise me, because C++ compilers is the context where I first read the name. I'm not saying this is incorrect, but I would find it amusing somehow.
- nkozyra 4y agoIt's fair to say that Walter is best known for his work with D rather than his work with C++, though.
- krylon 4y agoDepends on how old you are. ;-)
- benreesman 4y agoIndeed. He was a legend a long time before there was a D programming language.
- a9h74j 4y agoYes, Zortech C++: about 1991 IIRC. If this was not the first commercial compiler available on Windows, it was one of them.