新手常见问题汇总

10.8

I figured out a way to get the offsetof any member statically:

class A {
char a;
int b;
char c;
}

void main()
{
int[A.init.a.offsetof] x;
}

Unfortunately, I can't figure a way to get the class' size statically.
This doesn't work:

int[A.classinfo.init.length] x;

Any way to fetch the size of A?


Andrei

相关的信件

This question was on .learn, from where the answer (by Jarret) was:
__traits(classInstanceSize, Class)


========================================

Unfortunately, I can't figure a way to get the class' size statically.
>> This doesn't work:
>>
>> int[A.classinfo.init.length] x;
>>
>> Any way to fetch the size of A?
>>
>
> sizeof(A) doesn't work?
>
>

sizeof(A) doesn't compile.

A.sizeof == Object.sizeof == (void*).sizeof


[color=violet]8/4 更新[/color]

本贴将随时更新,大家有什么好经验请在跟贴中提供,提供地址也行,测试过的最好能告知测试环境,在归类整理时我会公示贡献人。为新来者减少障碍,我们一起努力!

一、开发环境编译器DMD、Buile工具dsss、IDE 配置
参见:[url]http://bbs.d-programming-language-china.org/index.php[/url]各板块有较详细的资料


安装tangosvn :

如果下载的是捆绑了dmd的,就不需要安装单独的dmd了,如果已经安装了单独的dmd,要把系统路径中dmd和dm的路径去掉,并配置好tango\bin下的sc.ini文件。

压缩包更新比较慢,建议使用svn下载,地址:[url]http://svn.dsource.org/projects/tango/trunk/[/url]。可以随时得到bug修复的版本,如果使用的是svn下载的版本,就需要安装单独的dmd了,并把dmd和dm的bin和lib路径设好。建议使用dmd和tango平行的目录,这样比较一目了然。


执行 tango\lib\build-dmd.bat
编译出: tango-base-dmd.lib

执行 tango\lib\build-tango.bat
编译出tango-user-dmd.lib

执行 tango\lib\build-win32.bat
编译出tango-win32-dmd.lib

执行 tango\lib\install-dmd.exe (很多文章里没有写)
会在\D\dmd目录下新建一个 \import 目录,会自动添加一些tango文件,并且会自动改写
D:\D\dmd\bin\sc.ini配置文件,还会将上面编译出的3个lib文件自动复制到dmd\lib目录下。剩下的就是手工配置好系统路径和ide后就可以工作了。


#dmd1033


二、中文资料:
参见:[url]http://bitworld.ys168.com/[/url] 中文手册,目前是dmd1.028
d圈子(论坛)[url]http://dlang.group.iteye.com/[/url] 高手较多


1、关闭控制台:
a、在 项目属性 ——〉编译器选项 中勾选“不显示控制台窗口”和“without console window”选项。(yidabu贡献)

b、在项目的 others 目录下建一 A.def 文件,添加如下两行内容:(bbs.dvole.com 提供的文件)
EXETYPE NT
SUBSYSTEM WINDOWS

保存后将 文件名 添加到 项目属性 ——〉编译器选项 ——〉额外选项 中即可。
两者选其一就可。[color=green]在Poseidon r239中可行[/color]。

2、让控制台停住:(kuan 贡献)
import std.stdio;   

void main()
{
//......
getch();
} //测试过


import std.process;   

void main()
{
//......
system( "pause" );
}

或用tango
import tango.io.Console;   

void main()
{
//......
Cin.get();
}



3、处理中文:
import std.stdio;
import std.c.locale;
import std.process;
void main(char[][] argv)
{
fwide(stdout, 1);
setlocale(0, "China");
writefln("你好,DMD");//d方式,也支持c的printf()方式,参见dmd1.028中文手册(上)10.1.20
system( "pause" );
} //目前在dmd2.013 win2003中,任何中文输出的都是人民币符号,不知为什么,解决后再修正



kuan 2010-03-25
1. import std.c.stdio, std.windows.charset, std.process;
2.
3. void main()
4. {
5. // TEST on DMD 1.056 and 2.042
6. printf( toMBSz("中文\n" ) );
7. printf( toMBSz("中文加ENGLISH加數字123456789\n" ) );
8. std.process.system( "pause" ); // pause
9. }
。。。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值