看看简单的示例(该示例不使用.di文件
):
这里
克隆它并放文件在方便的地方.
现在,试使用它.
在此例中,map.c
和app.d
在同一目录中.
import std.stdio : writeln;
//使用`map.c`
import map;
import std.string : toStringz;
alias c = toStringz;
void main()
{hashmap* m = hashmap_create();string key = "hello";hashmap_set(m, key.c, key.length, 400);uintptr_t result;if (hashmap_get(m, key.c, key.length, &result)){writeln(key, " = ", cast(int) result);}else{writeln("Could not locate entry ", key);}
}
如果路径设置正确,现在可运行:
dmd map.c app.d
DMD
现已生成可执行文件.运行它并查看结果.
好.现在,如果也可获得自动补全
等,那就更好了.