d

Where is “curl.lib” for DMD?

孤街醉人 提交于 2019-12-08 16:31:45
问题 When I import etc.c.curl; DMD tells me Warning 2: File Not Found curl.lib Where is this curl.lib? (I've tried several packages from http://curl.haxx.se/download.html but haven't found curl.lib there. MSVC package libcurl-7.19.3-win32-ssl-msvc.zip have a curllib.lib but DMD won't link with it.) 回答1: You can create curl.lib using implib. Implib is in the Basic Utilities download. Run it against your curllib.dll in /libcurl-7.19.3-win32-ssl-msvc/lib/Release/ like this: implib /s curl.lib curllib

d programming, parse or convert string to double

自闭症网瘾萝莉.ら 提交于 2019-12-08 15:59:32
问题 as easy as it is in other languages, i can't seem to find an option in the d programming language where i can convert a string (ex: "234.32") into a double/float/real. using atof from the std.c.stdio library only works when i use a constant string. (ex: atof("234.32") works but atof(tokens[i]); where tokens is an dynamic array with strings doesn't work). how to convert or parse a string into a real/double/float in the d-programming language? 回答1: Easy. import std.conv; import std.stdio; void

Is D's scope failure/success/exit necessary?

醉酒当歌 提交于 2019-12-08 14:39:28
问题 When using a language that has try/catch/finally, are D's failure/success/exit scope statements still useful? D doesn't seem to have finally which may explain why those statements are used in D. But with a language like C# is it useful? I am designing a language so if I see many pros I'll add it in. 回答1: scope(X) isn't necessary in the same way that for isn't necessary provided you have if and goto . Here's a paraphrased example from some code I've been writing today: sqlite3* db; sqlite3

Binding with SWIG - typedef'ed types bound incorrectly

我只是一个虾纸丫 提交于 2019-12-08 08:57:32
问题 I have swig.i file like that: %module ogr_api %{ #include "ogr_api.h" %} %inline %{ typedef void *OGRSFDriverH; %} /* OGRSFDriverRegistrar */ OGRDataSourceH OGROpen( const char *, int, OGRSFDriverH * )` and I get the following .c wrapper: ... SWIGEXPORT void * D_OGROpen(char * jarg1, int jarg2, void * jarg3) { ... That is SWIG translates OGRSFDriverH to just void*. I need to save the type name. How could I do it? Also I loss const in the first argument, but this is the next question. 回答1:

CDB command for setting a breakpoint based on a line number

一个人想着一个人 提交于 2019-12-08 06:26:27
问题 Is there a set of CDB commands for setting a breakpoint based on a line number? It seems that there is no "direct" one. Actually it seems that CDB knowledge is falling into a black hole and it's getting harder and harder to find resources on the Internet. My CDB setup cdb -c "l+*;.lines" and later I add the source lsf mySource.d Currently I put hard-coded breakpoints with a mixin enum brk = "debug{asm{int 3;}}"; // code mixin(brk); But it's not a viable solution. 回答1: The syntax to break in

GtkD (the Gtk+bindings for the D language) why compile it?

吃可爱长大的小学妹 提交于 2019-12-08 02:53:53
问题 I've recently been using GtkD with the D programming language to create native applications. I've downloaded all the necessary files and got everything running so i can now compile and produce sample apps. My question is that in some of the guides it tells you to compile GtkD on the platform you are using but what is the point? Once compiled you end up with a single lib file on Windows (GtkD.lib) and three lib files on Linux (ending in *.a). What are these files for and how are they used?

D: dmd saying something really bizarre

喜欢而已 提交于 2019-12-08 02:27:17
问题 I was writing a library for myself to help automate some really common tasks I've been doing in D for scripting from the command line. For reference, here is the code in its entirety: module libs.script; import std.stdio: readln; import std.array: split; import std.string: chomp; import std.file: File; //Library code for boring input processing and process invocation for command-line scripting. export: //Takes the args given to the program and an expected number of arguments. //If args is

Binding with SWIG - typedef'ed types bound incorrectly

孤人 提交于 2019-12-07 15:13:34
I have swig.i file like that: %module ogr_api %{ #include "ogr_api.h" %} %inline %{ typedef void *OGRSFDriverH; %} /* OGRSFDriverRegistrar */ OGRDataSourceH OGROpen( const char *, int, OGRSFDriverH * )` and I get the following .c wrapper: ... SWIGEXPORT void * D_OGROpen(char * jarg1, int jarg2, void * jarg3) { ... That is SWIG translates OGRSFDriverH to just void*. I need to save the type name. How could I do it? Also I loss const in the first argument, but this is the next question. Flexo Assuming I've understood your question correctly you have a number of opaque "handles" that in C are

Laziness in C++11

拥有回忆 提交于 2019-12-07 13:03:05
问题 Do you know how to perform a lazy evaluation of string, like in this D snippet: void log(lazy string msg) { static if (fooBarCondition) writefln(…) /* something with msg */ } Actually, the problem might not need laziness at all since the static if. Maybe it’s possible to discard char const* strings when not used? Like, in C++: void log(char const *msg) { #ifdef DEBUG cout << … << endl; /* something with msg */ #else /* nothing at all */ #endif } Any idea? Thank you. 回答1: #ifdef DEBUG #define

Single threaded future/promises in D?

会有一股神秘感。 提交于 2019-12-07 07:08:52
问题 I see that D has futures, and can create threads but is there anything like "Dart" futures/promises (or I guess javascript if you use a library)? I want to be able to write code like this - // // NOT D code because I can't remember all the syntax! // auto fut = myfile.read(); fut.then(function(data) { // Process data asynchronously when the future completes }; I want the callback on the same thread as the main code though. This will presumably need some kind of even queue and event