serve-d icon indicating copy to clipboard operation
serve-d copied to clipboard

Support C modules via ImportC

Open vladimmi opened this issue 2 years ago • 4 comments

At this point both DMD and LDC support compilation of C modules, automatically invoking external preprocessor for them if needed (DMD for some time, LDC since 1.33-beta2 version), dub also can treat C modules as part of project for building. Is it theoretically possible to have IDE support for this? I mean resolving C modules, having C functions in suggestions/goto, etc.

vladimmi avatar Jul 12 '23 17:07 vladimmi

Starting off, code completion and other features use the dparse library very heavily (imported from 20+ modules). That library can't parse c files.

As I believe the D compiler frontend emits a D AST for C source code, I have some ideas:

  • Let the D compiler convert the C file to a D file, probably losing line:col positions of tokens.
  • Prefer using the dmd compiler as a library over dparse?
  • Impement lexing and parsing of C code into a D AST in libdparse, regarding C as a subset of D (not too hard).

Take them with a grain of salt, I'm very new to this project.

jnms-me avatar May 11 '24 19:05 jnms-me