is dmd a virus?
is dmd a virus? https://www.virustotal.com report: Cybereason --> Malicious.779f29 VBA32 --> BScope.Trojan.DShell
Re: QtE56: QFormBuilder: Error: undefined identifier `QFormBuilder`
Probably did not compile QtE5-master/build/QtE56/qte56core.pro QtE5-master/build/QtE56/qte56widgets.pro Use QMAKE to build a DLL/SO More details by mail: m...@yandex.ru
To switch GC from FIFO to LIFO paradigm.
GC cleans memory using the FIFO paradigm. Is it possible to switch GC to work using the LIFO paradigm?
strip in stdin
string[] m = stdin.byLineCopy.array; How to make strip() for each line in an expression ...
Multi-threaded sorting of text file
Need help: There' s a large text file (hundreds of thousands of lines). The structure is as follows: 2345|wedwededwedwedwe .. 872625|rfrferwewweww . 23|rergrferfefer It is necessary to sort this file by the first field having received: 23|rergrferfefer... 2345|wedwededwedwedwe... 872625|rfrferwewweww... There are also N CPU (from 4 to 8) and 16 Gb of Memory. Necessary come up with an algorithm in D for fast sorting using multithreading.
dmd for Haiku OS
I have recently looked through Haiku OS and got surprised to find there dmd 2.072. There was only running file but Phobos and DrinTime were missing. Are there any plans to port dmd to Haiku OS nowadays? Is there a manual (example) on dmd porting on Haiku OS?
Re: QWebView requesting QtE5WebEng32.so on windows
On Saturday, 21 July 2018 at 19:11:08 UTC, Dr.No wrote: So I went to try out QWebView on Windows from this wrapper: https://github.com/MGWL/QtE5 all the examples went fine until I tried QWebView: Prior to version Qt-5.5 WebKit was used, and for later versions of chromium-based WebEngine. You probably have a WebKit-based version and need to use: Loader(dll.Qt5widgets + dll.QtE5Web, true)). LoadQt (...) for Windows 32/64 WebEngine contains a typo ... Must be DLL
Re: Why is it hard to make Qt bindings?
On Thursday, 5 July 2018 at 08:42:39 UTC, drug wrote: There were several attempts to make Qt binding for dlang ... QtE 5 works great on Win32/64, Linux 32/64 and Mac OS x 64. The main difference is that Qt5 uses a set of pre-defined slots and signals rather than creating them using a MOC or creating them dynamically as dqml. Qt5 has several large applications running on dozens of computers in different companies. If you use dynamic slots and signals from qml in Qt 5, you can fully play all the functionality of Qt5 with dlang. But this is a very big project of the future ...
Re: Is DWT busted?
On Friday, 8 June 2018 at 05:00:57 UTC, TheGag96 wrote: I'm sorry about bringing this into here instead of DWT's subforum, but it's somewhat dead and hasn't been getting a lot of attention. I decided to finally play around with DWT today and tried to build the example. I got this: Performing "debug" build using /usr/bin/dmd for x86_64. dwt:base 1.0.1+swt-3.4.1: target for configuration "library" is up to date. dwt 1.0.1+swt-3.4.1: target for configuration "linux-gtk" is up to date. main ~master: building configuration "application"... Linking... To force a rebuild of up-to-date targets, run again with --force. Running ./main Program exited with code -11 I'm on Pop!_OS (basically Ubuntu), x64, DMD 2.079.0. Every library they ask for is installed. I tried cloning the source and building their snippets, and none of them work. Other people have apparently had this same problem for the past few months, and none of them find a solution. What's going on here? IDK if this is any help, but here's the backtrace according to gdb: https://pastebin.com/Xd46YwwP Go to Gtk+ or Qt. They really work.
Re: C style callbacks fix for member callbacks
On Saturday, 19 May 2018 at 23:52:58 UTC, IntegratedDimensions wrote: I have a member callback that I want to use as a C callback. http://www.agner.org/optimize/calling_conventions.pdf https://www.youtube.com/watch?v=xhDS377mAc4
Re: interfacing c++
On Wednesday, 22 November 2017 at 08:29:26 UTC, MGW wrote: Possibly it will be interesting https://pp.userapi.com/c639524/v639524332/60240/uH3jnxrchik.jpg
Re: interfacing c++
On Tuesday, 21 November 2017 at 23:12:33 UTC, Markus wrote: hi, im trying to interface a cpp class. I'd like to interface a bigger library and I'm trying to figure out the minimum effort. Possibly it will be interesting https://www.youtube.com/watch?v=HTgJaRRfLPk
Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace
On Wednesday, 8 November 2017 at 06:34:27 UTC, Andrew Edwards wrote: I'm having a little bit of problem calling D code from C++ and would appreciate some assistance. First, given the following C++ program wich compiles, links, and runs without any problem: The useful material. https://www.youtube.com/watch?v=HTgJaRRfLPk
I need library for QR codes generation.
I need library for generation of QR codes. Who knows, give the link.
Re: Crypto.lib and ssl.lib for Win32
On Tuesday, 25 July 2017 at 21:51:39 UTC, Adam D. Ruppe wrote: On Tuesday, 25 July 2017 at 12:11:08 UTC, MGW wrote: Where can I find the ready made for usage or how to create cryptro.lib and ssl.lib for Windows 32 that are necessary for my project? Do you have the crypto.dll and ssl.dll? If so, implib can make the lib files. If you don't have implib, email the dlls to me and I'll get it to you (destructiona...@gmail.com) Thank you for your offer! I didn`t find crypto.dll and ssl.dll files for Win32 with the necessary list of export functions. but there`re files libssl32.dll and libeay32.dll (from OpenSSL for Windows) which have the necessary export functions. Can I use them instead of crypto.dll and ssl.dll? Is it possible to rename libssl32.dll to ssl.dll? One more question: Was the module http2.d check and did it operate in Win32? I understand that it works in Linux but I really need it working in Win32.
Crypto.lib and ssl.lib for Win32
I want to make an application with use http2.d from packet arsd. Where can I find the ready made for usage or how to create cryptro.lib and ssl.lib for Windows 32 that are necessary for my project?
Re: Help with an algorithm!
On Thursday, 15 June 2017 at 13:16:24 UTC, CRAIG DILLABAUGH wrote: The purpose - search of changes in file system. Sorting is a slow operation as well as hashing. Creation of a tree, is equally in sorting. So far the best result: string[] rez; foreach(str; m2) { bool fFind; int j; foreach(int i, s; m1) { if(str == s) { fFind = true; j = i; break; } } if(!fFind) { rez ~= str; } else {m1[j] = m1[$-1]; m1.length = m1.length - 1; } } // rez => rezult How to parallel on thred?
Help with an algorithm!
There are two arrays of string [] mas1, mas2; Size of each about 5M lines. By the size they different, but lines in both match for 95%. It is necessary to find all lines in an array of mas2 which differ from mas1. The principal criterion - speed. There are the 8th core processor and it is good to involve a multithreading.
Re: Extern C and Symbol Mangling
On Friday, 26 May 2017 at 12:49:27 UTC, Oleksii wrote: Hi, Call methods and property C++ from D. Interface C++ and D and their interaction. https://pp.userapi.com/c636630/v636630885/4657a/07wCn5hbHHo.jpg https://www.youtube.com/watch?v=HTgJaRRfLPk
Re: How to setup DLL and EXE projects in one VS solution
On Wednesday, 17 May 2017 at 19:48:42 UTC, Igor wrote: On Wednesday, 17 May 2017 at 18:03:04 UTC, Igor wrote: What exactly do mean by "binding"? Also I am wondering if using extern(C) as opposed to extern(D) only affects name mangling or am I losing some DLang possibilities since I am only calling DLang DLL from DLang EXE? Look at these materials, there can be they will are useful. https://vk.com/vk_dlang?z=photo-471951_456239025%2Fwall-471951_2095 https://www.youtube.com/watch?time_continue=2=HTgJaRRfLPk
Re: COM Expertise needed: COM Callbacks
On Monday, 24 April 2017 at 00:55:45 UTC, Nierjerson wrote: Still trying to get the com automation code working. This is a Please, use ZIP for archive.
Re: How to use C code in D
On Thursday, 23 March 2017 at 18:10:20 UTC, Dillen Meijboom wrote: Hi there, I'm learning D for a while because it's really easy to use C-code in D. The problem is that I don't really get how to deal with the data structures defined in C in D. Perhaps, it will be interesting to you. I advise to look at https://www.youtube.com/watch?v=HTgJaRRfLPk
Re: How do I call a C++ struct default constructor from D?
On Tuesday, 7 February 2017 at 13:37:01 UTC, Atila Neves wrote: Here still example https://pp.vk.me/c636630/v636630885/46579/neSdIip1ySI.jpg
Re: How do I call a C++ struct default constructor from D?
On Tuesday, 7 February 2017 at 13:37:01 UTC, Atila Neves wrote: On Tuesday, 7 February 2017 at 10:46:24 UTC, kinke wrote: I've only every done trivial C++ integration before. As soon as I tried something "real" it all broke down incredibly fast. Probably going to have to file some bugs on name mangling. Atila Perhaps this video will help https://www.youtube.com/watch?v=HTgJaRRfLPk
Re: How to repeat structure C++
On Monday, 16 January 2017 at 00:07:44 UTC, Adam D. Ruppe wrote: That's just interfaces and classes in D, so change struct to those words and go fro there. // --- jd.d: compile: dmd -c jd import std.stdio; extern (C++) interface IHome { int sum(int, int); }; extern (C++) void printIHome(void* ptr) { IHome ob = cast(jd.IHome)ptr; ob.sum(4, 5); } // --- jc.cpp compile: dmc jc.cpp jd.obj phobos.lib #include struct IHome { int sum(int a, int b) { int s = a+b; printf("a = %d, b = %d, sum = %d\n", a, b, s); return s; } }; extern "C" intrt_init(); extern "C" intrt_term(); extern void printIHome(void*); void main() { IHome iMyHome; rt_init(); // --- iMyHome.sum(2, 3); // Call C++ method in C++ IHome* ptriMyHome = printIHome(ptriMyHome);// Call C++ method in D --> ERROR :-( // --- rt_term(); } // compile -- dmd -c jd dmc jc.cpp jd.obj r:\dmd2\windows\lib\phobos.lib // --- Please, help to rewrite jd.d for the correct method call in structure С++.
Re: How to repeat structure C++
On Sunday, 15 January 2017 at 19:00:49 UTC, MGW wrote: Hi! struct IInterface {}; struct IMsgBox : public IInterface { virtual bool Confirm(const wchar* queryText, tVariant* retVal) = 0; virtual bool Alert(const wchar* text) = 0; };
How to repeat structure C++
Hi! I write plugin for 1C:Enterprise 8.3 on dmd now. https://youtu.be/apLppufZulI I try to repeat structure C++ (interface) on dmd. But D no inheritance of structures. What it is possible to replace with the D following code on C ++struct IInterface {}; C++ - struct IMsgBox : public IInterface { virtual bool Confirm(const wchar* queryText, tVariant* retVal) = 0; virtual bool Alert(const wchar* text) = 0; };
Re: the best language I have ever met(?)
On Wednesday, 23 November 2016 at 18:54:35 UTC, Igor Shirkalin wrote: Igor, is the good Russian-speaking forum https://vk.com/vk_dlang. There are articles on GUI and other aspects of dlang.
Re: Memory allocation failed. Why?
On Tuesday, 22 November 2016 at 15:53:39 UTC, Steven Schveighoffer wrote: On 11/21/16 11:53 AM, ag0aep6g wrote: Thank you very much for explaining such a difficult and slippery situation.
Re: Memory allocation failed. Why?
On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: import core.sys.windows.windows: MessageBoxA; void test() { for(int i; i != 10; i++) { ubyte[] buf; for(int j; j != 1; j++) buf ~= 65; MessageBoxA(null, "--on for--".ptr, "".ptr, 0); // delete buf; // if ON - then memory delete in step } MessageBoxA(null, "--off for--".ptr, "".ptr, 0); } void main() { test(); MessageBoxA(null, "--The end--".ptr, "".ptr, 0); } core.exception.OutOfMemoryError@src\core\exception.d(693): Memory allocation failed This short program doesn't work at Windows 32. Why GC doesn't release memory in case of its shortage in Windows! This is bug?
Memory allocation failed. Why?
import core.sys.windows.windows: MessageBoxA; void test() { for(int i; i != 10; i++) { ubyte[] buf; for(int j; j != 1; j++) buf ~= 65; MessageBoxA(null, "--on for--".ptr, "".ptr, 0); // delete buf; // if ON - then memory delete in step } MessageBoxA(null, "--off for--".ptr, "".ptr, 0); } void main() { test(); MessageBoxA(null, "--The end--".ptr, "".ptr, 0); } core.exception.OutOfMemoryError@src\core\exception.d(693): Memory allocation failed Simple program and error. Why? Windows 7 (32) dmd 2.072.0
Re: Popular embedded language for scripting in D
On Saturday, 19 November 2016 at 22:18:39 UTC, Sai wrote: I have seen luad and Walters own JavaScript VM that can be used in D for embedded scripting purpose in an application. I was wondering which is more popular among D applications? Any suggestions? Thanks, sai Look at one more option. https://forum.dlang.org/thread/trxrewjxncocihftj...@forum.dlang.org It is built already in GUI QtE5 (Qt-5) and has big documentation of Qt
Re: Configuring of dub for the application reading enviroment variable
On Friday, 30 September 2016 at 11:09:37 UTC, rikki cattermole wrote: There is no way to do this. it is necessary to add section to dub: "enviroment": [ { "LD_LIBRARY_PATH", "$PACKAGE_DIR" }, { "MY_VARIABLE", "$PACKAGE_DIR/IMAGES"} ]
Configuring of dub for the application reading enviroment variable
My STARTING application shall read the enviroment variable. For example MY_VARIABLE= "I'm Gena". The MY_VARIABLE variable needs to be set in dub.json so what she would be visible in case of start of my application. Purpose: to set LD_LIBRARY_PATH having specified a certain directory in dub packet. Please, write an example of dub.json for it.
dub - load shared library (so) in example
I make a packet for dub in Linux. In a packet there is libQt.so which is loaded by an example of D. Usually I execute LD_LIBRARY_PATH='pwd'; export LD_LIBRARY_PATH, but now it is necessary to make it in dub. How to make it?
Re: How to call a method of class D from function of C++ in DLL?
On Saturday, 27 August 2016 at 07:13:01 UTC, Nicholas Wilson wrote: easiest method would be to mark the D class extern(C++) noting that in C++ a D class reference becomes a pointer to the C++ class. In "the D class extern(C++)" do't work phobos.
How to call a method of class D from function of C++ in DLL?
Method which I use now: source D: - extern (C) { int on_metFromD(CEditWin* uk, int aa, int bb) { return (*uk).metFromD(int aa, int bb); } } class CEditWin { . . . // Method for to call int metFromD(int a, int b) { return a + b; } } main() { CEditWin f = new CEditWin(); void* pf = // save pf and _metFromD in DLL toTransferInDLL(pf, _metFromD); } source C++ DLL -- extern "C" typedef int (*execDmet1)(void*, int, int); extern "C" void toTransferInDLL(void* pf, void* on_metFromD) { int rez = ((execDmet1)on_metFromD)(pf, 2, 3); } - How to change a code that it was possible transferring two parameters in C++ ( toTransferInDLL(pf, _metFromD) ) directly to call a method D. How to call delegate from C++
Re: D, GTK, Qt, wx,…
How can we build QtE5 and/or the examples? Download qte5.zip from github. Unzip it to qte5-master. If you have Windows 32 then copy qte5-master/windows32/QtE5Widgets32.dll to folder qte5-master. Copy RunTime Qt-5 (all files and folders from qte5-master/windows32/rt_Qt5_windows32.zip) to qte5-master folder. Copy files from qte5-master/examples to qte5-master folder. Make: dmd example1 qte5 Run: example1
Re: D, GTK, Qt, wx,…
On Sunday, 29 May 2016 at 11:03:36 UTC, Russel Winder wrote: GKT+ has a reputation for being dreadful on OSX and even worse on Windows. Qt on the other hand has a reputation for being the most portable – though clearly wx is (arguable) the most portable. QtE5 - is my wrapper for Qt-5 https://www.youtube.com/watch?v=DuOl-4g117E https://github.com/MGWL/QtE5
Is it bug compiler?
Windows 7 32bit --- import std.stdio; import std.conv; class CFormaMain { ~this() { char[] zz = [ 'A', 'B', 'C' ]; writeln(to!string(zz)); } } int main(string[] args) { CFormaMain formaMain; formaMain = new CFormaMain(); return 0; } --- core.exception.InvalidMemoryOperationError@src\core\exception.d(693): Invalid me mory operation
Re: D --> C++ --> D
On Thursday, 31 March 2016 at 11:47:34 UTC, MGW wrote: -- Help me to optimize this source code. How to apply here delegates and generally whether possibly to make it here
D --> C++ --> D
I for myself write Qt-5 wrapper. I use calls from Qt (C ++) as extern (C) calls. Prompt how to write this code well and with use of abilities to integrate D and C ++ -- // ex4.d - Concepts of QAction.QtE5 // compile - // dmd ex4 qte5 import core.runtime; import qte5;// wrapping Qt-5 // (1) handler receives the pointer on object of myQWidget. // (2) and call method in class myQWidget extern (C) void handler(myQWidget* wd) { (*wd).kn1Press(); } class myQWidget : QWidget { this() { // Create widget and set size super(this); resize(200, 100); // Create button for demo signal -- slot // button generates to us a signal auto kn1 = new QPushButton("Press me ...", this); // Create QAction for processings of the slot auto actSlot1 = new QAction(this, , aThis); // We connect a signal to slots standard means connects(kn1, "clicked()", actSlot1, "Slot()"); } // (2) to process clicking of the button void kn1Press() { msgbox("pressed key on the form"); } } int main(string[] args) { // Load library QtE5 if (1 == LoadQt(dll.QtE5Widgets, true)) return 1; // Create app QApplication app = new QApplication(, Runtime.cArgs.argv, 1); // (1) Create obj of myQWidget and to save this address in obj myQWidget mywid = new myQWidget(); mywid.saveThis().show; app.exec(); return 0; } --
Re: Get address of object in constructor.
On Sunday, 13 March 2016 at 16:02:07 UTC, WebFreak001 wrote: However note that this is not the same as that function. cast(void*)this and are 2 different things. So if you want to do the same as saveThis just do void* thisAddr = cast(void*) instead void* thisAddr = cast(void*) Error compile: Deprecation: this is not an lvalue
Re: Get address of object in constructor.
On Sunday, 13 March 2016 at 15:49:20 UTC, WebFreak001 wrote: On Sunday, 13 March 2016 at 15:43:02 UTC, MGW wrote: I want to get address of object Cfoo in constructor. Whether it is possible? class Cfoo { void* adrThis; this() { adrThis = cast(void*) this; } } ... Cfoo foo = new Cfoo(); "this" should work (pun intended) Super! Ok!
Get address of object in constructor.
I want to get address of object Cfoo in constructor. Whether it is possible? now: - class Cfoo { void* adrThis; void saveThis(void* adr) { adrThis = adr; } } ... Cfoo foo = new Cfoo(); foo.saveThis(); shall be -- class Cfoo { void* adrThis; this() { adrThis = ? } } ... Cfoo foo = new Cfoo();
Re: Error with associative array initializer DMD32 D Compiler v2.070.0
The citation from https://dlang.org/spec/hash-map.html Static Initialization of AAs immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; unittest { assert(aa["foo"] == 5); assert(aa["bar"] == 10); assert(aa["baz"] == 2000); } Judging by the text, it is static initialization, during compilation.
Error with associative array initializer DMD32 D Compiler v2.070.0
immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; ... Error: non-constant expression ["foo":5L, "bar":10L, "baz":2000L]
Problem with dmd 2.068 Win 32
Hi! My project has an error link: Error 42: Symbol Undefined _D6object9Exception6__ctorMFNaNbNfAyaAyakC6object9ThrowableZC9Exception On dmd 2.067.* everything gathered without mistakes. Where to look for a mistake?
Re: Problem with dmd 2.068 Win 32
Thanks to all! The problem is localized!
Exec function D from C++
Linux 32, dmd 2.067.0 I want to connect and execute function D from main() C++. d1.d import core.stdc.stdio; extern (C++) void d1() { printf(printf - exec d1()); } main_c1.cpp #include stdio.h void d1(void); int main(void) { d1(); return 0; } compile dmd -c d1.d gcc main_c1.cpp d1.o libphobos2.a -lpthread -o main_c1 ./main_c1 --- This option works correctly! If I try to cause the functions connected to GC in the D function, there is an error. d1.d import import std.stdio; extern (C++) void d1() { writeln(writeln - exec d1()); } compile dmd -c d1.d gcc main_c1.cpp d1.o libphobos2.a -lpthread -o main_c1 ./main_c1 --- Error: './main_c1' terminated by signal SIGSEGV (Address boundary error) Examples from dmd2/html/d/dll-linux.html don't work if instead of printf() to use writeln(). I think that a problem in initialization of Phobos.
Re: Error execute MS function fputc()
I found the solution. A problem in different structures of FILE for MSVC and DMC. I take the pointer on structure of FILE from CrtDLL.dll Everything works! // MGW 07.05.15 import core.runtime; // Загрузка DLL Для Win import std.stdio;// writeln version(Windows) { import std.c.windows.windows; // GetProcAddress для Windows } alias extern (C) int function(int, FILE*) t_fputc; t_fputc ms_fputc; int main(string[] args) { version(Windows) {auto libCrtDll = CrtDll.dll; } // Load CrtDLL.DLL MS Windows auto h = Runtime.loadLibrary(libCrtDll); // Find function fputc ms_fputc = cast(t_fputc)GetProcAddress(h, fputc); // Find array struct FILE MS void* ubuf = cast(void*)GetProcAddress(h, _iob); import core.stdc.stdio: stdout; try { // stdout -- FILE dmc auto rez = ms_fputc('A' , core.stdc.stdio.stdout); } catch { writeln(Error execute MS function fputc();); } try { // cast(FILE*)(ubuf + 0) == stdin MSVC // cast(FILE*)(ubuf + 32) == stdout MSVC // stdout -- FILE MSVC auto rez = ms_fputc('B' , cast(FILE*)(ubuf + 32)); } catch { writeln(Error execute MS function ms_fputc();); } return 0; }
Mistake of opening of a file having a name in cp1251.
Greetings to all! I work on Windows with cp1251 and I have a mistake in the program: import std.stdio; int main (string [] args) { string nameFile = `«Ёлки с объектами №876».txt`; File f = File (nameFile, w); f.writeln (Greetings!); return 0; } This mistake of a kind: std.exception. ErrnoException@std\stdio.d (372): Cannot open file ` ┬л╨Б ╨╗╨║╨╕ ╨Ю ╨▒ ╤К ╨╡╨║╤ 876 ┬╗. txt ' in mode ` w ' (Invalid argument) For correction of this mistake I had to change a file std\stdio.d, having added in it function fromUtf8toAnsiW (). The piece of an source code of a file std\stdio.d with changes is presented more low. private FILE* fopen(in char[] name, in char[] mode = r) @trusted // nothrow @nogc - mgw отключено из-за fromUtf8toAnsiW { import std.internal.cstring : tempCString; version(Windows) { // 02.04.2015 8:31:19 repair for dmd 2.067.0 wchar* fromUtf8toAnsiW(in char[] s, uint codePage = 0) @trusted { import std.c.windows.windows: WideCharToMultiByte, GetLastError; import std.windows.syserror: sysErrorString; import std.conv: to; char[] result, rez; int readLen; auto ws = std.utf.toUTF16z(s); result.length = WideCharToMultiByte(codePage, 0, ws, -1, null, 0, null, null); if (result.length) { readLen = WideCharToMultiByte(codePage, 0, ws, -1, result.ptr, to!int(result.length), null, null); for(int i; i != result.length; i++) { rez ~= result[i]; rez ~= 0; } rez ~= 0; rez ~= 0; } if (!readLen || readLen != result.length) { throw new Exception(Couldn't convert string: ~ sysErrorString(GetLastError())); } return cast(wchar*)rez.ptr; } import std.internal.cstring : tempCStringW; // return _wfopen(name.tempCStringW(), mode.tempCStringW()); return _wfopen(fromUtf8toAnsiW(name), mode.tempCStringW()); } else version(Posix) { import core.sys.posix.stdio : fopen; return fopen(name.tempCString(), mode.tempCString()); } else { return .fopen(name.tempCString(), mode.tempCString()); } } With the given correction all works correctly. Question. Whether correctly such change from the point of view of programming canons on D ?
Re: Mistake of opening of a file having a name in cp1251.
The decision, which I have applied using function fromUtf8toAnsiW() already works correctly. I use dmd 2.067.0
Re: Dynamically Loading a D DLL From a C Program in Linux
// MGW 05.01.14 // We model in D object C ++ QByteArray from Qt. // // Windows: dmd st1.d // Linux: dmd st1.d -L-ldl import core.runtime; // Load DLL for Win import std.stdio;// writeln version(linux) { import core.sys.posix.dlfcn; // declare dlopen() и dlsym() // On Linux these functions are not defined in core.runtime, here and it was necessary to add. extern (C) void* rt_loadLibrary(const char* name) { return dlopen(name, RTLD_GLOBAL || RTLD_LAZY); } void* GetProcAddress(void* hLib, string nameFun) { return dlsym(hLib, nameFun.ptr);} } version(Windows) { import std.c.windows.windows; // GetProcAddress для Windows } //it is important!!! //At definition constructs and functions of members the attribute extern (C) is obligatory! alias extern (C) void function(void*, char*) t_QByteArray_QByteArray; t_QByteArray_QByteArray QByteArray_QByteArray; alias extern (C) void* function(void*, char, int) t_QByteArray_fill;t_QByteArray_fill QByteArray_fill; // Struct QByteArray from qbytearray.h in include directory. // inline char *QByteArray::data() { detach(); return d-data; } где d есть Data* struct Data { void* rref; int alloc; int size; char* data; // Here actually behind what it is necessary for us, the index on a file of bytes char array[1]; } // == Experimental class DQByteArray == class DQByteArray { Data* QtObj; // Object: QtObj - its size of 4 bytes (32 digit version) // -- // class D, call class C++ this(char* buf) { QByteArray_QByteArray(QtObj, buf); } ~this() { // It is possible to find ~this and here it to register, but it is routine } // inline char *QByteArray::data() { detach(); return d-data; } где d есть Data* char* data() { return (*QtObj).data; } // D: Data** == C++: QByteArray Here also it became clear, that such object With ++, looking at it from D void* fill(char ch, int resize=-1) { return QByteArray_fill(QtObj, ch, resize); } } int main(string[] args) { // Files with QByteArray C++ version(linux) {auto nameQtCore = libQtCore.so; } version(Windows) {auto nameQtCore = QtCore4.dll; } auto h = Runtime.loadLibrary(nameQtCore); // Load dll или so // It is QByteArray::QByteArray(char*); QByteArray_QByteArray = cast(t_QByteArray_QByteArray)GetProcAddress(h, _ZN10QByteArrayC1EPKc); // QByteArray::fill(char*, int); QByteArray_fill = cast(t_QByteArray_fill)GetProcAddress(h, _ZN10QByteArray4fillEci); // Create my class DQByteArray ba = new DQByteArray(cast(char*)ABC.ptr); printf(\n ba.data() = %s, ba.data()); // Test fill() from C++ ba.fill('Z', 5); printf(\n ba.data() = %s, ba.data()); return 0; }