DLang 2.095.0 version has been released . This version mainly enhances the support for Objective-C, adds the ability to declare the Objective-C protocol, and improves the entire compiler, library and tools. A total of 27 major changes and 78 fixes from 61 contributors are included. Some highlights are as follows:
- C++ header generation
For some time, DMD has included experimental support for generating C++ header files from D source code via the -CH command-line option to facilitate calling the D library from C++. For example, given the following D source file.
CPP-ex.d
external (C ++): struct A { int x; } void printA(ref A a) { import std.stdio : writeln; writeln(a); }
And the following command line:
dmd -HC cpp-ex.d
The compiler outputs the following to stdout (-HCf specifies a file name, -HCd specifies a directory).
// Automatically generated by Digital Mars D Compiler #pragma once #include <assert.h> #include <stddef.h> #include <stdint.h> #include <math.h> #ifdef CUSTOM_D_ARRAY_TYPE #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE #else /// Represents a D [] array template<typename T> struct _d_dynamicArray { size_t length; T *ptr; _d_dynamicArray() : length(0), ptr(NULL) { } _d_dynamicArray(size_t length_in, T *ptr_in) : length(length_in), ptr(ptr_in) { } T& operator[](const size_t idx) { assert(idx < length); return ptr[idx]; } const T& operator[](const size_t idx) const { assert(idx < length); return ptr[idx]; } }; #endif struct A; struct A { int32_t x; A() : x() { } }; extern void printA(A& a);
Many fixes and improvements have been made to this feature in this version. It should be noted that the generation of C headers is also supported through -H, -Hf and -Hd.
- Default C++ standard changes
The C++11 standard is now used by default. In addition, the compiler will now accept -extern-std=c++20. In practice, the only effect at present is to change the compile-time value, __traits(getTargetInfo, "cppStd"), but new types may be added in the future.
- Improved Objective-C support
This version enhances the compatibility of Objective-C by supporting the Objective-C protocol. This is achieved by reusing the interface in the context of extern (Objective-C). In addition, the @optional and @selector attributes help to accomplish this task.
- Improved compile-time feedback
For more details, please check the change log: https://dlang.org/changelog/2.095.0.html
Download link: http://downloads.dlang.org/releases/2.x/2.095.0/