Re: Windows Defender won't let me install DMD
On Monday, 18 February 2019 at 19:34:31 UTC, Seb wrote: On Monday, 18 February 2019 at 16:32:26 UTC, belkin wrote: I am trying to install the compiler and get started on learning D again ( attempted and stopped way back ) This is the error message I am getting. I am on Windows 10. Windows Defender SmartScreen prevented an unrecognized app from starting. Running this app might put your PC at risk. App: dmd-2.084.1.exe Publisher: Unknown publisher There was a error/oversight with the 2.084.1 release. It accidentally didn't get signed, you can try 2.084.0 if you are afraid of the warning. The next release (2.085.0) should be signed again. Works. Thanks
Windows Defender won't let me install DMD
I am trying to install the compiler and get started on learning D again ( attempted and stopped way back ) This is the error message I am getting. I am on Windows 10. Windows Defender SmartScreen prevented an unrecognized app from starting. Running this app might put your PC at risk. App: dmd-2.084.1.exe Publisher: Unknown publisher Additional question as a beginner. What do I need to install to get started. Obviously I need a compiler (which one is best ). But I also want an IDE and so far it seems Visual D would be a best choice. Ideas?
How to define and use a custom comparison function
I am new to D so I am probably not using the right terminology but here is a piece of C++ code (not complete) that I would like to translate to idiomatic D. I have defined a function object that I pass to std::sort to std:map as follows: enum class SortOrder{ ASC, DESC }; typedef std::vectorboost::variant DataRow; // this is one row of data in a 2D array. Data items are variants but this is not very important typedef std::vectorDataRow Data; // this is simply a 2D array Data the_data; // the function object is here. I don't want a lamda because I want to be able to call this from multiple places class MyCompare { public: explicit MyCompare(int column, SortOrder order) : m_column(column), m_order(order) {} bool operator()(const DataRow lhs, const DataRow rhs) { switch (m_order) { case SortOrder::ASC: return lhs[m_column] rhs[m_column]; case SortOrder::DESC: return rhs[m_column] lhs[m_column]; } } private: int m_column; SortOrder m_order; }; example 1: int column = 3; SortOrder order = DESC; std::sort(the_data.begin(), the_data.end(), MyCompare(column, order)); example 2: MyCompare comp(column, order); std::mapDataRow, Data, MyCompare mp( comp ); What is the equivalent idiomatic D?
Basics of calling C from D
Example: I have this C function that is compiled into a library //File: factorial.h int factorial(int n); //File: factorial.c #include factorial.h int factorial(int n) { if(n!=1) return n*factorial(n-1); } Question: How do I use it from D?
Re: Basics of calling C from D
On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote: On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote: Example: I have this C function that is compiled into a library //File: factorial.h int factorial(int n); //File: factorial.c #include factorial.h int factorial(int n) { if(n!=1) return n*factorial(n-1); } Question: How do I use it from D? //File: blah.d extern(C) int factorial(int n); //coincidentally identical to the C declaration. void main() { assert(factorial(3) == 6); } $ gcc -c factorial.c -ofactorial.o $ dmd blah.d factorial.o $ ./blah or $ gcc -c factorial.c -ofactorial.o $ ar rcs libfactorial.a factorial.o $ dmd blah.d -L-lfactorial $ ./blah Basically, you just translate the header files from C to D, then link to the C implementation. See http://code.dlang.org/packages/dstep for automatic translation of headers. This is great. How practical (reliable ) is it to translate a large and complex header file like oci.h ( the interface for Oracle's database API ) to D?
Re: Basics of calling C from D
On Wednesday, 11 June 2014 at 14:22:51 UTC, Adam D. Ruppe wrote: On Wednesday, 11 June 2014 at 14:11:04 UTC, simendsjo wrote: I believe the correct answer should be Buy my book!. ah, of course! I should just make a .sig file lol http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book chapter 4 talks about this kind of thing :P Thanks. This book is on my To Buy list.