小编sho*_*lte的帖子

选项卡上的Bash变量扩展完成

我正在运行Ubuntu 11.04,当我尝试在以变量开头的路径上使用bash中的tab-completion时,我会看到一些奇怪的行为.如果我有TOP =/scratch,我尝试tab-complete:

cd $ TOP/foo

它变为:

cd\$ TOP/foo

我更喜欢它完成:cd $ TOP/foobar或cd/scratch/foobar但我会满足于它只是不改变线并要求我取消$.

有谁知道bash/readline在哪里我应该解决这个问题?

bash readline bash-completion

29
推荐指数
2
解决办法
8344
查看次数

在D中实现C API

因此,有很多关于从D内部调用C API的信息,但反过来怎么样?在D中编写一个像普通C共享库一样工作的库需要做什么?这是一个简单的案例:

main.c中

extern int foo(int x);
void main() {
    printf("foo(5)=%d\n",foo(5));
}
Run Code Online (Sandbox Code Playgroud)

餐饮

extern(C)
{
    int foo(int x)
    {
         return x*x;
    }
}
Run Code Online (Sandbox Code Playgroud)

天真地尝试使用gcc和dmd构建和链接这些只会导致链接器错误.

链接gcc main.o foo.o:

doFoo.o: In function `no symbol':
doFoo.d:(.text+0x7): undefined reference to `_Dmodule_ref'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

与dmd main.o foo.o链接:

/usr/lib64/libphobos2.a(deh2_2eb_525.o): In function `_D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable':
src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0xa): undefined reference to `_deh_beg'
src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x14): undefined reference to `_deh_beg'
src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x1e): undefined reference to `_deh_end'
src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x46): undefined reference to `_deh_end'
/usr/lib64/libphobos2.a(lifetime.o): In function `_D2rt8lifetime18_sharedStaticCtor9FZv':
src/rt/lifetime.d:(.text._D2rt8lifetime18_sharedStaticCtor9FZv+0x15): undefined reference to `_tlsend'
src/rt/lifetime.d:(.text._D2rt8lifetime18_sharedStaticCtor9FZv+0x29): …
Run Code Online (Sandbox Code Playgroud)

c d

18
推荐指数
3
解决办法
1309
查看次数

标签 统计

bash ×1

bash-completion ×1

c ×1

d ×1

readline ×1