dmd

Super-weird issue triggering “Segmentation Fault”

柔情痞子 提交于 2020-03-03 04:57:08
问题 I won't go very deep into the issue (the codebase is already thousands of lines and quite complex), so I'll try to miniminise the... "window" to what I've spotted. Here's the routine triggering the "Segmentation Fault" : extern (C) { void* Statements_new() { return cast(void*)(new Statements()); } void Statements_add(Statements s, Statement st) { //writeln("In here"); if (s is null) writeln("StatemenTS are null"); else writeln("not null : "~ typeid(s).name); if (st is null) writeln("statement

Statically linking SQLite with DMD (Windows x86)

笑着哭i 提交于 2020-01-01 10:28:09
问题 I've tried to statically link with sqlite3 without success. I'm using the 'etc.c.sqlite3' header, and the sqlite3 amalgamation. To create the .lib file I've tried both VC++ and MinGW-gcc, both of these compile the source file successfully - but they both generate COFF object format (optlink, which DMD uses, works with OMF). After reading tons of posts on 'digitalmars.D', I've tried several different solutions. objconv: tried to convert lib file created with GCC, resulted in undefined symbols

What is a “yield return” equivalent in the D programming language?

佐手、 提交于 2019-12-31 09:11:09
问题 Here is a simple generator in C#. IEnumerable<int> Foo() { int a = 1, b = 1; while(true) { yield return b; int temp = a + b; a = b; b = temp; } } How do I write a similar generator in Digital Mars D? (The question is about the yield return statement) Thanks! Update. That's interesting. Since I'm just generating a mathematical sequence, using recurrence may be a good option. auto fib = recurrence!("a[n-1] + a[n-2]")(1, 1); foreach (e; take(fib, 10)) // <- prints first ten numbers from the

DMD vs. GDC vs. LDC

纵饮孤独 提交于 2019-12-31 08:33:09
问题 What are the Pros/Cons of the different D Compilers? How is the performance and the standard compliance/D2 support? How well are debuggers supported? How good are the Error messages and is the IDE integration? How good is the 64 bit support? My thought so far: DMD Mature and well maintained Only one platform, 64 bit support is not good Not FOSS GDC Supports various platforms Has very mature optimizations, so it's fast? Out of date runtime? GCC so a good debugger support? LDC Supports various

Using a foreach loop — variable cannot be read

我怕爱的太早我们不能终老 提交于 2019-12-23 16:06:23
问题 Should be rather simple but it's not. Here's my code : string cases() { string ret = ""; string[] methods; methods = [__traits(derivedMembers,mixin("Math"))]; foreach (string s; methods) ret ~= "case \"" ~ s ~ "\": return Math."~s~"(params);"; methods = [__traits(derivedMembers,mixin("OtherClass"))]; foreach (string s; methods) ret ~= "case \"" ~ s ~ "\": return OtherClass."~s~"(params);"; return ret; } string execute(string what, string[] params) { switch (what) { mixin(cases()); default:

Showing D Coverage Results as Overlays in Source Buffer

风格不统一 提交于 2019-12-23 03:32:22
问题 The D language compiler DMD outputs its coverage analysis in a file containing the original source as | inout(Ix)[] prefix() inout | { 2037| assert(!keys.empty); 2037| final switch (keys.length) | { 000000000| case 1: 000000000| return keys.at!0[]; 2037| case 2: | import std.algorithm.searching : commonPrefix; 2037| return commonPrefix(keys.at!0[], keys.at!1[]); | } | } that is, the original source where each line has been prefixed by a 10-character column containing the execution count (if

How to compile D application without the D runtime?

早过忘川 提交于 2019-12-20 23:22:18
问题 Iv been trying to figure this one out forever, and its starting to annoy me. I understand the D runtime library. What it is, what it does. I also understand that you can compile a D app without it. Like what XoMB does. Well, XoMB defines its own runtime, but there are cases where you dont need to write your own, if you dont need it. I understand that the DigitalMars D compiler (dmd) which is what im using, does alot of things behind the scenes for the runtime, like emiting references to

GtkD undefined reference

試著忘記壹切 提交于 2019-12-11 05:16:59
问题 My code: import gtk.MainWindow; import gtk.Main; void main(string[] args) { Main.init(args); auto win=new MainWindow("Hello World"); win.setDefaultSize(200,100); win.showAll(); Main.run(); } When I try to compile with DMD (or gdc), I get the errors: dmd ./test.d -L-L/usr/local/include/d/gtkd-2/lib test.o:(.data+0x10): undefined reference to `_D3gtk10MainWindow12__ModuleInfoZ' test.o:(.data+0x18): undefined reference to `_D3gtk4Main12__ModuleInfoZ' test.o: In function `_Dmain': ./test.d:(.text

error instantiating redBlackTree template

做~自己de王妃 提交于 2019-12-10 14:47:35
问题 I'm having trouble instantiating a RedBlackTree container with chars, but it works with ints: import std.stdio; import std.container; void main() { auto r1 = redBlackTree!(int)(); // works auto r2 = redBlackTree!(char)(); // error instantiating } I'm using DMD32 D Compiler v2.060. Any thoughts? Thanks. 回答1: you need to use a type that is comparable (i.e. can use the < operator or provide your own comparator as the second template parameter char (and wchar) is only useful for use in arrays due

Why is readf not behaving as expected?

偶尔善良 提交于 2019-12-10 13:56:13
问题 import std.stdio; void main(){ int n; while(readf("%d", &n)){ if(n == 11) break; writeln(n); } } The first iteration works, and it prints n , but after that readf() never returns. The documentation has only a single line explaining readf() : uint readf(A...)(in char[] for­mat, A args); For­mat­ted read one line from stdin. Am I do something wrong? or is there something wrong with readf() ? I just need to read numbers from the standard input. using: DMD 2.054 64-bit 回答1: I believe it's because