Skip to content

Commit

Permalink
Fix bugzilla issue 24669 - Make -i work with C modules (#16776)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuukk authored and adamdruppe committed Sep 20, 2024
1 parent f1171f0 commit c70dcbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/dmd.import-c-i.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Using the compiler flag `-i` will now properly pick up C source files

Previously you needed to manually include .c source files, it now works just like with .d files
2 changes: 1 addition & 1 deletion compiler/src/dmd/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extern (C++) struct Compiler
*/
extern(C++) static bool onImport(Module m)
{
if (includeImports && m.filetype == FileType.d)
if (includeImports && (m.filetype == FileType.d || m.filetype == FileType.c))
{
if (includeImportedModuleCheck(ModuleComponentRange(
m.md ? m.md.packages : [], m.ident, m.isPackageFile)))
Expand Down
8 changes: 8 additions & 0 deletions compiler/test/compilable/test16776.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// ARG_SETS: -i
// PERMUTE_ARGS:
// LINK:
import imports.cstuff3;
void main()
{
int s = squared(2);
}

0 comments on commit c70dcbc

Please sign in to comment.