TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Adding Modules to C in 10 Lines of Code [pdf]

138 pointsby pmarinalmost 3 years ago

4 comments

Shadonototraalmost 3 years ago
ImportC is shaping up to be one of the greatest feature of D<p>Being able to just import your C code, and call it from C, or when you need to go back to C and resume your work by just importing your D modules<p>I tried it, while it still need some finish, it worked very well! (you had to put your files through a preprocessor though, hopefully this step won&#x27;t be needed in the future)<p>Every modern language should include a C compiler, it is stupid to give up the entire C ecosystem!<p>No wonder Walter&#x27;s name is &quot;Bright&quot;!<p>To the people who still doubt about D &quot;because of the GC&quot;, it doesn&#x27;t exist for me, i am making an online 3D game targeting WASM without it, with all the language features!<p>For cases when you need one &quot;if you use D as a scripting language&quot;, it will be very helpful to have!<p><a href="https:&#x2F;&#x2F;www.kdom.xyz&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.kdom.xyz&#x2F;</a><p>If you love C, but need something modern with more safeties, give D a try!<p>D is a pragmatic language, very powerful, covers everyone&#x27;s needs!<p>If you tried it before, now is the time to give it another try!
评论 #31893801 未加载
评论 #31898287 未加载
评论 #31892541 未加载
评论 #31973966 未加载
评论 #31898298 未加载
评论 #31896232 未加载
评论 #31893455 未加载
评论 #31892626 未加载
unsafecastalmost 3 years ago
I&#x27;ve done something different before:<p><pre><code> &#x2F;&#x2F; main.c #include &lt;module.c&gt; int main() { moduleFunction(); } &#x2F;&#x2F; module.c #include &lt;stdio.h&gt; void moduleFunction() { printf(&quot;calling modules&quot;); } </code></pre> This has its issues (you can&#x27;t do parallel compilation anymore; you don&#x27;t have unexported functions, etc), but it works fine for small things. Super helpful when I want to make a small thing and don&#x27;t want to bother with headers.<p>You just include all the C files in one file and be done with it.
评论 #31892479 未加载
评论 #31893251 未加载
评论 #31892558 未加载
评论 #31895401 未加载
bachmeieralmost 3 years ago
On the topic of the presentation, I&#x27;d be happy to have a way to kill the preprocessor. Not that I expect that to happen. Reading C code is like reading literature that only makes sense if you know eight languages, four of which are known to fewer than 100 people.
评论 #31898228 未加载
评论 #31897550 未加载
评论 #31896224 未加载
评论 #31898512 未加载
khoobid_shomaalmost 3 years ago
The title is a bit misleading. This is about extending C grammar used in D.