我正在爲自己寫一個庫,以幫助自動執行一些我在D中用於從命令行執行腳本的常見任務。作爲參考,在這裏被全部代碼:D:dmd說一些真奇怪的東西
module libs.script;
import std.stdio: readln;
import std.array: split;
import std.string: chomp;
import std.file: File;
//Library code for boring input processing and process invocation for command-line scripting.
export:
//Takes the args given to the program and an expected number of arguments.
//If args is lacking, it will try to grab the arguments it needs from stdin.
//Returns the arguments packed into an array, or null if malformed or missing.
string[] readInput(in string[] args, in size_t expected) {
string[] packed = args.dup;
if (args.length != expected) {
auto line = split(chomp(readln()), " ");
if (line.length == (expected - args.length))
packed ~= line;
else
packed = null;
}
return packed;
}
//Digs through the .conf file given by path_to_config for a match for name_to_match in the first column.
//Returns the rest of the row in the .conf file if a match is found, and null otherwise.
string[] readConfig (in string path_to_config, in string name_to_match) {
string[] packed = null;
auto config = File(path_to_config,"r");
while (!config.eof()) {
auto line = split(chomp(config.readln()), ":");
if (line[0] == name_to_match)
packed = line[1..$];
if (packed !is null)
break;
}
config.close(); //safety measure
return packed;
}
現在,當我嘗試編譯這在調試模式(DMD -debug),我得到這個錯誤信息:
Error 42: Symbol Undefined __adDupT
script.obj(script)
Error 42: Symbol Undefined __d_arrayappendT
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio4File6__dtorMFZv
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio4File3eofMxFNaNdZb
script.obj(script)
Error 42: Symbol Undefined __d_framehandler
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio4File5closeMFZv
script.obj(script)
Error 42: Symbol Undefined _D3std6string12__ModuleInfoZ
script.obj(script)
Error 42: Symbol Undefined _D3std5stdio12__ModuleInfoZ
OPTLINK : Warning 134: No Start Address
--- errorlevel 36
我有絕對不知道我在這裏做錯了什麼。我使用的是Windows 7,如果有幫助的話。
警告134意味着你正在編譯爲一個應用程序而不是庫 –