Questions tagged [d]

D is a multi-paradigm systems programming language developed by Walter Bright and, since 2006, Andrei Alexandrescu. Now, D is an open source collaboration.

Filter by
Sorted by
Tagged with
0 votes
0 answers
33 views

SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &red) returns OpenGL error 502 [closed]

SDL version 2.26.2 OpenGL core version 4.0 I am using SDL to for window and context creation for an OpenGL project. I set RGB to be 8 bits, doublebuffered, then create my window and context. Once my ...
0 votes
0 answers
30 views

hyperscan __aligned_malloc issue in windows

I am trying to build and use the hyperscan on Windows. When i executed cmake -G "Visual Studio 15 2017 Win64" ..\ i could see the message -- Looking for posix_memalign -- Looking for ...
  • 7,938
0 votes
0 answers
126 views

SFML D bindings: libsfml-system.so.2.5: cannot open shared object file:

I recently did a fresh install of CSFML and I am getting this errors when running my program: object.Exception@source/app.d(38): Fatal error(s) encountered whilst calling `loadSFML()` function: [&...
2 votes
1 answer
51 views

Fixing an object oriented wrapper I am creating for bindbc.sfml

I am trying to create object oriented wrappers around bindbc.sfml, this is because I don't like the C-style syntax of CSFML. The C-style syntax is not right -- in my opinion -- for an object oriented ...
0 votes
1 answer
48 views

ctypes python create string structure

I have a struct like below in dlang struct gph { string x; string y; } and a function as follows: pragma(mangle, "print_gph") void print_gph(gph g) { stderr.writeln(g.x); } ...
  • 7,938
0 votes
1 answer
64 views

CSFML D: Missing symbol errors

I am using the official (dynamic) D bindings to CSFML (https://github.com/BindBC/bindbc-sfml). As a prerequisite, I installed CSFML 2.5 using the following command (my operating system is Linux): sudo ...
2 votes
2 answers
74 views

using File().byLine() with fold()

I am trying to use the fold operation on a range returned by byLine(). I want the lambda which is passed to fold to be a multi-line function. I have searched google and read the documentation, but ...
1 vote
1 answer
69 views

Call Dlang function in struct with Python ctypes

I have a .so (written in Dlang) which has a struct as below struct A { static A* load(string folder) { } } I am trying to consume the .so in Python. I am not sure how can i call the function ...
  • 7,938
0 votes
1 answer
48 views

How do I pass build optimisation when using `dub run`?

Is it possible to use D's O optimisation when using dub run command line? The package manager is absolutely fantastic, and just wondering if it is possible to pass along the following switches. -O -...
  • 517
1 vote
0 answers
143 views

Dlangui hello world program exit with non-zero code

I'm new to D and DlangUI, and I'm compiling a hello world app using DlangUI following the official wiki using vscode, I have edited the app.d file and run dub run, it shows Program exited with code -...
  • 1,465
0 votes
1 answer
88 views

How to properly setup Vibe-d server with mysql-native

I have vibe-d program that is used as a proxy for links. I use mysql-native to connect to SQL. It works, but the service dies after 20s - 2mins on higher traffic. I didn't see any specific error ...
  • 37
0 votes
1 answer
183 views

Extracting char* from a str PyObject in Python 3

Have anybody tried extracting a char* from a Python 3 PyObject* having type name str? Normal strings in Python 3 have type name str in the C API. For Python 2 one can use PyString_Check() and ...
  • 11.7k
2 votes
1 answer
155 views

How does AVR support with LLVM work for different languages?

Apologies in advance since I am not too knowledgeable on the topic yet and still in the process of learning about the inner workings of compilers. I am currently investigating the possibility of using ...
  • 45
0 votes
1 answer
50 views

Passing T and T[] arguments freely intermixed

Is there are reason why void f(T)(T[] params...) {} can't be passed freely intermixed T's and array of T's such as f(1,2,[3,4]); or f([1,2],3,[4],[5,6]); ?
  • 11.7k
1 vote
1 answer
62 views

Can I implement operator overloading for D's SumType alias?

TLDR: Is there a way make D's SumType play nice with opCmp while maintaining its functionality? Context I'm writing a program for which D's native SumType works almost completely. However, I would ...
3 votes
1 answer
86 views

Unable to recursively multiply BigInt beyond a certain number of iterations at compile-time in D

I need to get the product of an arbitrary number of variables. The actual number of variables and their values will be known at compile-time, however I cannot hardcode these because they come from ...
1 vote
1 answer
45 views

SHIFT-F6 as menu shortcut

In my current code I have the code MenuItem runFileItem = new MenuItem( (MenuItem mi) => pm.runFile(), "_Run file", "activate", true, accelGroup, 'r', ModifierType....
  • 18.5k
0 votes
1 answer
71 views

Failing to connect to MySQL in Dlang with vibe-d and mysql-native

I have simple vibe-D program which is trying to connect to SQL: import std.stdio; import mysql; import vibe.d; void main() { MySQLPool db_pool = new MySQLPool("localhost","root",&...
  • 37
1 vote
1 answer
162 views

How to interface to C++ from D correctly?

I tried to inteface between C++ and D. The problem is that I can't compile it. I used the code/command line on the website > g++ -c foo.cpp > dmd bar.d foo.o -L-lstdc++ && ./bar and it ...
  • 21
3 votes
2 answers
196 views

How do I get the current Unix timestamp in milliseconds, in D?

How can I get the current unix timestamp (milliseconds since January 1st, 1970) as a long variable? In other words, how would I implement this function? long getUnixTimestampMillis() { }
1 vote
3 answers
201 views

D language import local module

I am new to D language. i have a project A. When i executed dub build it has created me libA.so. i am trying to create a different .d file and import this module. now i wanted to write a D wrapper to ...
  • 13
0 votes
1 answer
77 views

VS code Dlang: can't change build config

I am giving D a shot with the VS code extension code-d. Everything works fine, except that I can't switch configuration, arch type or build type. If I try to do any of these things, I receive the ...
  • 2,009
2 votes
1 answer
105 views

Returning a filtered range

I'm looking at filtering ranges, and getting a little confused. In D, I can write this code: import std.stdio; import std.range; import std.algorithm; auto filterNums(int[] vals) { int limit = 3; ...
  • 3,384
2 votes
1 answer
128 views

Returning by reference from struct method in D

I'm starting my journey in D from C++. In C++ passing by reference or value is quite explicit, but in D it seems to vary between structs and classes. My question is how can I force a return by ...
  • 3,384
0 votes
0 answers
68 views

Undefined structures and functions from WinInet import

I'm making my first steps with D, and as a trial I am trying to access a SOAP API via the Internet. I have a working C++ app (Visual Studio 2019, Windows 10) which uses the wininet library. I am using ...
  • 3,384
2 votes
1 answer
111 views

Where is D's `std.sumtype`?

I'm working on a project in the D language and I want to use a module from the standard library called std.sumtype. I'm on debian oldstable, and I've tried both GDC and LDC. DMD is unavailable, ...
0 votes
2 answers
114 views

How do you define a decimal number in a PEG grammar?

I have the following grammar Arithmetic: Term < Factor (Add / Sub)* Add < "+" Factor Sub < "-" Factor Factor < Primary (Mul / Div)* ...
2 votes
2 answers
188 views

Is it possible to create a contiguous multidimensional array at runtime in D?

I would like to create a rectangular multidimensional array at runtime, such that the entire array is stored in a contiguous block of memory. It is not necessary for the array to be resizable after ...
  • 1,694
0 votes
1 answer
81 views

Converting C "srand(time(NULL));" to D language

What's the equivalent in D language for C statement srand(time(NULL));
0 votes
1 answer
504 views

VS Code custom run configuration for D

Is there a way to add a custom run configuration that would run a current file in the terminal? Currently no extensions exist for debugging .d files on Visual Studio Code. I still can manually enter ...
3 votes
2 answers
141 views

dlang incompatible type error in checking string

i have this code to check if string have j character import std.stdio; void main() { const string name = "john"; for (int i = 0;i < name.length;i++) { if (name[i] == &...
1 vote
1 answer
64 views

D language: I can't split a text block copied from a Wikipedia unicode chart into a list of single-letter strings. Output comes out wrong in editor

The MWE and the only code you need to see this is the following: module unicode_support; import std.string; const wstring unicodeVarSource = ` 𝐀 𝐁 𝐂 𝐃 𝐄 𝐅 𝐆 𝐇 𝐈 𝐉 𝐊 𝐋 𝐌 𝐍 ...
0 votes
1 answer
98 views

How to do string formatting in BetterC mode?

I'd like to use something like the "Concepts" package from Atila Neves. I implemented the check of an object against a type signature myself in a simple naive way. I can check struct objects ...
1 vote
2 answers
99 views

How to get string input from a socket in D?

I'm using this code to listen to a port: int start(){ ushort port = 61888; listener = new TcpSocket(); assert(listener.isAlive); listener.blocking = false; ...
1 vote
2 answers
67 views

How do I build a DAllegro project using dub?

I'm fairly new to D, and wish to use allegro for graphics. I also want to use dub to build my project. However, after running dub add allegro (https://code.dlang.org/packages/allegro), and trying to ...
  • 43
0 votes
1 answer
38 views

Unable to read a text file using `std.file.readText(fileName)` in Visual D (throws strange exception)

The exception details are: Unhandled exception at 0x00007FF7B11A7F40 in mutation_lib.exe: 0xC0000096: Privileged instruction. And it occurs at this line in the standard library source: void[] read(R)(...
1 vote
1 answer
87 views

Problems using malloc in D language: why writeln call the destructor twice in this example

I am trying to write a D wrapper for a C library (libmpdec) that stores its data using the standard C malloc function. But the are some nasty bugs in my programs that I don't know how to solve. So I ...
0 votes
1 answer
56 views

How to get the template argument of an alias-this-struct via is-expression in D?

I was playing around with alias this which can simulate inheritance for structs in D. For a library that I recently started I also would like to provide trait templates which detect the proper type ...
2 votes
2 answers
56 views

Inconsitent behaviour with computation of "greatest product given 'n' adjacent digits" (D language)

I'm working on a solution for Project Euler (problem 8) which involves working out the largest product of thirteen adjacent digits. I wrote a solution (below) but it doesn't seem to be outputting the ...
  • 65
0 votes
0 answers
203 views

How to store MongoClient in session store

What is the best way to store client connection? It needs in order to each request didn't request authorization to mongo. When I try: auto msettings = new MongoClientSettings(); MongoClient client = ...
2 votes
0 answers
127 views

Why does switching draw call order mess things up using Cairo and Win32 layered windows?

I'm working on a Win32 app with layered windows. The window contents are drawn using Cairo. The transparency is very unpredictable however. Sometimes everything is correct; opaque parts are opaque, ...
  • 33
1 vote
0 answers
101 views

Fasteest algorithm to compute avg distance between two Sets of points

Please see picture : Given the set of points marked in Red, I take two consecutive points (here 0 and 1 - these numbers are just for illustration , thus not the index in the array holding these ...
  • 769
2 votes
2 answers
152 views

How do you print or capture the current module name?

I want to print the module name of my main source file in that source file. I tried this: import std.stdio; import std.traits; // moduleName template int main(string[] args) { writeln("The ...
  • 6,670
2 votes
2 answers
549 views

Error: A dynamic link library (DLL) initialization routine failed on electron but it's fine on node js

I'm trying to load a custom module in electron written in D with node_dlang package, which is fine with node, but it fails within electron. the test with node, that runs just fine, goes like this: ...
  • 16.1k
0 votes
2 answers
207 views

Unexpected '\n' when converting from type string to type int while converting user input to int from string

I get a mysterious error when I compile my code I wrote in dlang it shows "Unexpected '\n' when converting from type string to type int" I checked it on google but I did not find a solution (...
0 votes
0 answers
100 views

Linear regression error - line slope wrong

Consider this function: double calculate_geoHeading(double [] x, double [] y) { /+ +++++++++ ++ This function will return the heading of the best fit line ++ +/ double r; ...
  • 769
-2 votes
1 answer
993 views

Compiler Explorer Assembly Output for C, C++ and D (dlang) [closed]

When using Compiler Explorer (https://godbolt.org/) to compare assembly output of simple programs, why D language assembly output is so long compared to C or C++ output. The simple square function ...
1 vote
4 answers
225 views

Destructured iteration over variadic arguments like a tuple sequence in D

Let's say I want to process a variadic function which alternately gets passed start and end values of 1 or more intervals and it should return a range of random values in those intervals. You can ...
1 vote
0 answers
64 views

Sorting Json struct from vibe.d

I faced a problem with wrong sorting JSON keys. I use mongo db and I need to send a creating user form command. vibe-d JSON: Json a2 = Json([ "createUser": ...
0 votes
1 answer
52 views

Having trouble with package.d

I am having trouble with D's package.d feature. I have my package.d file: module dew; public import dew.util; I then have util.d: module dew.util; struct Size { int width; int height; } ...
user avatar

1
2 3 4 5
53