[Issue 14674] Importing std.stdio causes another module to become undefined

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jun 10 07:46:03 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14674

--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to sigsve from comment #2)
> Undefined symbols for architecture x86_64:
>   "_D5Stack12__ModuleInfoZ", referenced from:
>       _D4Main12__ModuleInfoZ in Main.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)

It says a ModuleInfo symbol of Stack module is missing.

(In reply to sigsve from comment #3)
> Sorry, I though DMD compiled and linked Stack.d automagically(Which it seems
> to have done, when I do not import std.stdio)

If you don't list a module file in dmd command line, the symbols in it are
compiled (== semantic analysis done) but those code won't be output to any
object files.

When you don't add `import std.stdio;` in Stack.d, today's dmd fortunately
determines the ModuleInfo object of Stack module is unnecessary, so the build
will succeed. However it's just undocumented behavior, and might be changed in
the future.

So I'd recommend to compile and link Stack.d always when you import it from
other modules.

--


More information about the Digitalmars-d-bugs mailing list