Re: Entry point errors when using LDC to compile Windows Subsystem module with -m32

2018-09-20 Thread kinke via Digitalmars-d-learn
On Thursday, 20 September 2018 at 20:48:50 UTC, spikespaz wrote: I downloaded a known-good 32-bit libcurl.dll to distribute with the project I just figured that the multilib package is indeed missing a 32-bit libcurl.dll. It can be found in the bin dir of the win32 package (which btw is the

Re: Entry point errors when using LDC to compile Windows Subsystem module with -m32

2018-09-20 Thread kinke via Digitalmars-d-learn
On Thursday, 20 September 2018 at 20:48:50 UTC, spikespaz wrote: When comping with the command below, I get linker errors saying that '/SUBSYSTEM:WINDOWS" isn't recognized and is ignored Then you're most likely accidentally using DMD's link.exe. When using a multilib LDC build on Win64 and

Re: ldc2 crashes when trying to compile my app

2018-09-01 Thread kinke via Digitalmars-d-learn
On Saturday, 1 September 2018 at 19:35:53 UTC, Per Nordlöw wrote: What should I grep for when trying to Dustmite this? `_Z7DtoLValP6DValue` may be suitable. - I don't use dustmite and prefer manual minimization; e.g., by adding `-vv > bla.log` to the crashing commandline. The last lines in

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-09-01 Thread kinke via Digitalmars-d-learn
On Saturday, 1 September 2018 at 18:46:32 UTC, Nordlöw wrote: Thanks! Is there usually only apps and not libs that are supposed to have linker flags like these? In this specific case, I'm not sure it's a good idea to set the linker in the dub config. Does it absolutely require gold, i.e.,

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-08-30 Thread kinke via Digitalmars-d-learn
On Thursday, 30 August 2018 at 19:41:38 UTC, Nordlöw wrote: I'm using the tar.xz for x64 Linux. Ok? You're explicitly adding `-link-internally` in your top-level dub.sdl: dflags "-link-internally" platform="linux-ldc" # use GNU gold linker If you want to go with gold, as your comment

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-08-30 Thread kinke via Digitalmars-d-learn
Nope, I now think this is more likely an issue with the default config (etc/ldc2.conf). It contains a new section for WebAssembly, which specificies `-link-internally`, which seems to be wrongly used for non-WebAssembly too in your case. I take it you're not using an official package, but a

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-08-30 Thread kinke via Digitalmars-d-learn
On Thursday, 30 August 2018 at 13:36:58 UTC, Per Nordlöw wrote: [...] LDC uses the C compiler as linker driver by default, exactly because the linker needs some setup (default lib dirs etc.). So this is almost certainly a dub issue.

Re: Cross compile windows programs on linux

2018-08-24 Thread kinke via Digitalmars-d-learn
On Friday, 24 August 2018 at 13:10:40 UTC, John Burton wrote: Is in the subject. Are there any cross compilers that will run on a linux system but compile D code using Win32 into a windows .exe file, preferably 64 bit? I can find hints of cross compilers but not really seen anything packaged

Re: Trouble with LDC2 and definition file to hide console?

2018-08-20 Thread kinke via Digitalmars-d-learn
For LDC, just rename your main() to WinMain(). Or alternatively, `-L/SUBSYSTEM:WINDOWS -L/ENTRY:mainCRTStartup` in the LDC cmdline.

Re: Trouble with LDC2 and definition file to hide console?

2018-08-20 Thread kinke via Digitalmars-d-learn
On Monday, 20 August 2018 at 13:49:19 UTC, rikki cattermole wrote: That is for Optlink not for MSVC link which ldc uses. Exactly. For LDC, just rename your main() to WinMain().

Re: Static initialization of static arrays is weird

2018-08-19 Thread kinke via Digitalmars-d-learn
On Sunday, 19 August 2018 at 11:20:41 UTC, Dennis wrote: I have a two dimensional static array in a game board struct and want to explicitly set the default value for each cell. Now typing the whole 9x9 array out would be cumbersome and I can't change the default constructor of a struct, so I

Re: Compiler build error

2018-08-04 Thread kinke via Digitalmars-d-learn
On Saturday, 4 August 2018 at 18:12:05 UTC, Alex wrote: /snap/ldc2/78/bin/ldc2(_start+0x29)[0x8b7ee9] You haven't specified the DMD version you are using. Your LDC is 'outdated', so make sure to first check whether it still fails with an up-to-date version before potentially wasting time.

Re: Compiler build error

2018-08-04 Thread kinke via Digitalmars-d-learn
On Saturday, 4 August 2018 at 13:29:36 UTC, kinke wrote: [...] as it features debuginfos Sorry, scrach that (it used to for the Windows CI build but doesn't anymore).

Re: Compiler build error

2018-08-04 Thread kinke via Digitalmars-d-learn
You're most likely hitting an ICE in the front-end (as both compilers crash). What you can always do is invoke the compiler in a GDB session. That's especially useful with an LDC CI build (download: https://github.com/ldc-developers/ldc/releases/tag/CI), as it features debuginfos and enabled

Re: Dlang on OpenWrt

2018-08-02 Thread kinke via Digitalmars-d-learn
You could give LDC's armhf build a try. It's built on Debian Jessie and requires ARMv6 or newer, so it might work. Download: https://github.com/ldc-developers/ldc/releases

Re: pointer cast from const(Y) to immutable(void*)** is not supported at compile time

2018-08-02 Thread kinke via Digitalmars-d-learn
On Thursday, 2 August 2018 at 02:13:41 UTC, Hakan Aras wrote: I do want it at compiletime though. Totally understandable; that's a regression and needs to be fixed. See https://github.com/dlang/dmd/pull/8362#pullrequestreview-142565787.

Re: Where is TypeInfo_Class.m_init set

2018-08-02 Thread kinke via Digitalmars-d-learn
On Thursday, 2 August 2018 at 02:52:44 UTC, Hakan Aras wrote: LDC complains about the type of initializer though: onlineapp.d(22): Error: Global variable type does not match previous declaration with same mangled name: _D5bclib3Baz6__initZ onlineapp.d(22):Previous IR type: %bclib.Baz

Re: Where is TypeInfo_Class.m_init set

2018-07-31 Thread kinke via Digitalmars-d-learn
Sorry, scratch that, I forgot the `extern` before the dummy global. After fixing that, I didn't quickly find a solution for referencing the symbol in the .data.rel.ro section (LLVM asm, e.g., `void* getInit() { return __asm!(void*)("movq test.C.__init, %rax", "={rax}"); }` doesn't work

Re: Where is TypeInfo_Class.m_init set

2018-07-31 Thread kinke via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 01:16:29 UTC, Hakan Aras wrote: I was hoping it would be possible without tinkering with the compiler, but it doesn't seem to be the case. I've been playing around with LDC. There is an init symbol for classes, which is normally used as payload for the ClassInfo's

Re: Is there any plan for a dependency-free subset of "core" runtime?

2018-07-19 Thread kinke via Digitalmars-d-learn
On Thursday, 19 July 2018 at 12:44:30 UTC, Radu wrote: --- int foo() { import std.algorithm, std.range; auto r = 100.iota.stride(2).take(5); return r.sum(); } --- ldc2 -mtriple=wasm32-unknown-unknown-wasm -betterC -link-internally -L-allow-undefined -release -Os wasm.d

Re: Issues with undefined symbols when using Vibe on Windows

2018-07-04 Thread kinke via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 20:36:55 UTC, Chris M. wrote: On Tuesday, 3 July 2018 at 18:35:43 UTC, kinke wrote: On Tuesday, 3 July 2018 at 17:54:08 UTC, Seb wrote: [...] AFAICT, the issue is that MinGW is used, as opposed to MinGW-w64 (a confusingly separate project unfortunately AFAIK).

Re: Issues with undefined symbols when using Vibe on Windows

2018-07-03 Thread kinke via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 17:54:08 UTC, Seb wrote: BTW in case someone has a bit of time to look at the MinGW headers. They are built as part of the `build-mingw-libs` branch at the installer repo: https://github.com/dlang/installer/blob/build-mingw-libs/windows/build_mingw.bat This is

Re: C API / const char *text / std.string.toStringz pointer is always NULL on C side

2018-05-19 Thread kinke via Digitalmars-d-learn
On Saturday, 19 May 2018 at 17:33:08 UTC, Robert M. Münch wrote: On 2018-05-18 14:42:17 +, Adam D. Ruppe said: A value struct return is actually done via a hidden pointer parameter (so the function can construct it in-place for the caller, a standard optimization), so it just shifted all

Re: LDC phobos2-ldc.lib(json.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'

2018-05-04 Thread kinke via Digitalmars-d-learn
On Thursday, 3 May 2018 at 23:47:40 UTC, IntegratedDimensions wrote: Maybe this is a cross compilation issue? Looks like you simply didn't download the LDC multilib package.

Re: C++ / Wrong function signature generated for reference parameter

2018-05-03 Thread kinke via Digitalmars-d-learn
On Thursday, 3 May 2018 at 07:00:03 UTC, Robert M. Münch wrote: using struct won't give the correct signature That's why there's `extern(C++, class) struct Image`, see https://dlang.org/spec/cpp_interface.html#classes. Not sure about the const part too, if this is correct on the D side...

Re: Are Fibers just broken in D?

2018-04-24 Thread kinke via Digitalmars-d-learn
On Tuesday, 24 April 2018 at 16:22:04 UTC, Steven Schveighoffer wrote: On 4/24/18 10:31 AM, Byron Heads wrote: I will start ignoring win32 when win64 doesn't require dealing with visual studio installs. Also I have a feeling a client will ask for it. Unfortunately I don't think the VS

Re: ldc flags for beginner

2018-04-22 Thread kinke via Digitalmars-d-learn
On Sunday, 22 April 2018 at 14:05:53 UTC, kinke wrote: On Sunday, 22 April 2018 at 02:08:40 UTC, fevasu wrote: what flags to use so that the intermediate .o files are discared by ldc and only a.out is written to disk There's no such functionality, the .o files are required as linker input.

Re: ldc flags for beginner

2018-04-22 Thread kinke via Digitalmars-d-learn
On Sunday, 22 April 2018 at 02:08:40 UTC, fevasu wrote: what flags to use so that the intermediate .o files are discared by ldc and only a.out is written to disk There's no such functionality, the .o files are required as linker input. You can place the object files into some temp dir with

Re: Ldc on Windows

2018-04-17 Thread kinke via Digitalmars-d-learn
On Tuesday, 17 April 2018 at 11:01:21 UTC, Nicholas Wilson wrote: You should also be able to use -link-internally /LLMV's lld if you don't want to install MSVC Nope, the MSVC libs are still required, and no, the ancient ones shipping with DMD can't be used.

Re: Destructor call

2018-04-10 Thread kinke via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 18:34:54 UTC, n0fun wrote: Why the destructor is called in the second case and why not in the first? The first case is RAII, where destruction isn't done for not fully constructed instances. The second case is GC finalization at program shutdown and looks like a

Re: Benchmarking sigmoid function between C and D

2018-04-09 Thread kinke via Digitalmars-d-learn
On Saturday, 7 April 2018 at 21:53:23 UTC, Guillaume Piolat wrote: Have you tried LLVM intrinsics? say llvm_exp While LLVM does have math intrinsics, they seem to boil down to C runtime calls in many/most cases. I.e., on Linux x86_64, `llvm_exp(real)` simply maps to the C function `expl()`

Re: Benchmarking sigmoid function between C and D

2018-04-08 Thread kinke via Digitalmars-d-learn
On Sunday, 8 April 2018 at 05:35:10 UTC, Arun Chandrasekaran wrote: Did you also generate the bar graph plot using D? Heh nope, I used LibreOffice Calc for that.

Re: Benchmarking sigmoid function between C and D

2018-04-07 Thread kinke via Digitalmars-d-learn
On Saturday, 7 April 2018 at 20:33:13 UTC, Arun Chandrasekaran wrote: Much better with mir.math.common, still a bit slower than C (even with larger loops): As this appears to be benchmarking mostly the std.math.exp(float) performance - some/many basic algos in std.math, incl. exp(), are

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-27 Thread kinke via Digitalmars-d-learn
On Monday, 26 March 2018 at 23:32:59 UTC, Nordlöw wrote: forwarded as `-L-flto=thin` but still errors as Which is wrong, it's not a ld command-line option (i.e., the `-L` prefix is wrong). I don't use dub though, so I don't know how to fix it.

Re: Aggressive conditional inlining with ldc only, not dmd

2018-03-25 Thread kinke via Digitalmars-d-learn
On Sunday, 25 March 2018 at 22:09:43 UTC, Nordlöw wrote: And I haven't found a way to conditionally qualify these inner loop functions with `pragma(inline, true)` for the ldc case only. From https://dlang.org/spec/pragma.html#inline: 'If inside a function, it affects the function it is

Re: inline asm return values

2018-03-25 Thread kinke via Digitalmars-d-learn
On Sunday, 25 March 2018 at 10:58:37 UTC, Dave Jones wrote: Is this stuff documented somewhere? See https://dlang.org/spec/abi.html#function_calling_conventions. It defines the D calling convention for Win32 (int return value in EAX) and states that it matches the C calling convention on

Re: dub / win 64 / unresolved externals from run-time lib?

2018-03-08 Thread kinke via Digitalmars-d-learn
On Thursday, 8 March 2018 at 17:03:18 UTC, Robert M. Münch wrote: Using Dub and pretty simple setup, that links in 3 C/C++ static libraries, I get these linker errors: libyogacore.lib(Yoga.obj) : error LNK2019: unresolved external symbol __imp_fmodf referenced in function "void __cdecl

Re: Fastest way to zero a slice of memory

2018-03-05 Thread kinke via Digitalmars-d-learn
On Sunday, 4 March 2018 at 15:23:41 UTC, Nordlöw wrote: When zeroing a slice of memory (either stack or heap) such as enum n = 100; ubyte[n] chunk; should I use `memset` such as memset(chunk.ptr, 0, n/2); // zero first half or an array assignment such as chunk[0 .. n/2] = 0;

Re: inline @trusted code

2018-01-30 Thread kinke via Digitalmars-d-learn
On Tuesday, 30 January 2018 at 15:05:38 UTC, ikod wrote: Hello, Several times I faced with next problem: I have "@safe" routine with few calls to @system functions inside: OS calls (recv, send, kqueue) os some phobos unsafe functions like assumeUnique. I'd like not to wrap these @system

Re: Class instance memory overhead lower than 3 words?

2018-01-25 Thread kinke via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 21:48:21 UTC, Nordlöw wrote: Why is the memory overhead for a class instance as high as 3 words (24 bytes on 64-bit systems? I find that annoyingly much for my knowledge database application. I'm aware of extern(C++), having one word overhead, but such

Re: __gshared as part of alias

2018-01-17 Thread kinke via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 22:01:57 UTC, Johan Engelen wrote: ``` struct GSharedVariable(AddrSpace as, T) { static __gshared T val; alias val this; } alias Global(T) = GSharedVariable!(AddrSpace.Global, T); Global!float bar1; // __gshared ``` Only 1 value per T though. ;)

Re: Range over a container r-value with disabled postblit

2018-01-14 Thread kinke via Digitalmars-d-learn
On Sunday, 14 January 2018 at 01:38:17 UTC, Nordlöw wrote: My current proposal for a solution is to make `byElement` a free unary function byElement(auto ref X x) which statically checks via static if (__traits(isRef, x)) whether the `X`-instance is passed as either an - l-value,

Re: DMD Test Suite Windows

2017-12-18 Thread kinke via Digitalmars-d-learn
On Monday, 18 December 2017 at 16:06:33 UTC, Jonathan Marler wrote: Trying to run the dmd test suite on windows, looks like Digital Mars "make" doesn't work with the Makefile, I tried Gnu Make 3.81 but no luck with that either. Anyone know which version of make it is supposed to work with on

Re: initializing a static array

2017-10-10 Thread kinke via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 22:00:27 UTC, kinke wrote: [...] Ah sorry, overlooked that it's the initializer for a struct field.

Re: initializing a static array

2017-10-10 Thread kinke via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 14:15:07 UTC, Simon Bürger wrote: On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote: Maybe: double[n] bar = 0.repeat(n).array; This works fine, thanks a lot. I would have expected `.array` to return a dynamic array. But apparently the compiler

Re: Need importing dcompute.lib into my project

2017-10-07 Thread kinke via Digitalmars-d-learn
On Saturday, 7 October 2017 at 09:04:26 UTC, kerdemdemir wrote: Error: static assert "Need to use a DCompute enabled compiler" Are you using latest LDC 1.4? The CUDA backend wasn't enabled for earlier versions.

Re: static this not run?

2017-09-30 Thread kinke via Digitalmars-d-learn
On Saturday, 30 September 2017 at 12:07:21 UTC, Nicholas Wilson wrote: Hmm. Everything except for the main function was in a different module, I dont see why that would cause it to not be run, but then bugs have a tendency to do strange things like that. I'll have to dust mite DCompute and see

Re: Is it possible to specify the address returned by the address of operator?

2017-09-28 Thread kinke via Digitalmars-d-learn
On Thursday, 28 September 2017 at 10:24:28 UTC, Jonathan M Davis wrote: On Wednesday, September 27, 2017 22:01:26 DreadKyller via Digitalmars-d- learn wrote: Also off-topic slightly, but am I the only one with massive latency on this site? It took like almost 2 minutes from me hitting reply

Re: Sectioned variables?

2017-09-28 Thread kinke via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 11:59:16 UTC, Arav Ka wrote: GCC supports a `__attribute((section("...")))` for variables to put them in specific sections in the final assembly. Is there any way this can be achieved in D? Does GDC support this? LDC does, see

Re: erros em printf[AJUDA]

2017-09-08 Thread kinke via Digitalmars-d-learn
On Friday, 8 September 2017 at 22:30:16 UTC, dark777 wrote: ex3.d(19): Error: cannot pass dynamic arrays to extern(C) vararg functions printf("Writef Hello %.*s!\n", name.length, name.ptr);

Re: 24-bit int

2017-09-02 Thread kinke via Digitalmars-d-learn
On Saturday, 2 September 2017 at 02:37:08 UTC, Mike Parker wrote: It's not a bug, but a feature. Data structure alignment is important for efficient reads, so several languages (D, C, C++, Ada, and more) will automatically pad structs so that they can maintain specific byte alignments. On a

Re: struct field initialization

2017-08-16 Thread kinke via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 18:11:05 UTC, bitwise wrote: If I define a non-default constructor for a struct, are the fields initialized to T.init by the time it's called? The struct instance is initialized with T.init before invoking the constructor.

Re: D on Power8 (PPC64)

2017-08-07 Thread kinke via Digitalmars-d-learn
On Monday, 7 August 2017 at 20:39:40 UTC, Dmitry Olshansky wrote: What is the status of the platform? I might be doing some number crunching on one of the power8 beasts, would be nice to have D working there. Not that bad afaik. LDC should be able to build itself, the runtime libs and their

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread kinke via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:39:16 UTC, Stefan Koch wrote: On Friday, 30 June 2017 at 16:29:22 UTC, kinke wrote: On Friday, 30 June 2017 at 16:21:18 UTC, kinke wrote: CTFE only (incl. parsing of literals). Just make sure you don't happen to call a std.math function only accepting reals; I

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread kinke via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:21:18 UTC, kinke wrote: CTFE only (incl. parsing of literals). Just make sure you don't happen to call a std.math function only accepting reals; I don't know how many of those are still around. Oh, apparently most still are. There are even some mean overloads

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread kinke via Digitalmars-d-learn
On Friday, 30 June 2017 at 11:42:39 UTC, Luis wrote: On Thursday, 29 June 2017 at 12:00:53 UTC, Simon Bürger wrote: Thanks a lot for your comments. On Wednesday, 28 June 2017 at 23:56:42 UTC, Stefan Koch wrote: [...] This is only happening on CTFE ? Enforcing to use the old 8086 FPU for

Re: Force usage of double (instead of higher precision)

2017-06-28 Thread kinke via Digitalmars-d-learn
On Wednesday, 28 June 2017 at 22:16:48 UTC, Simon Bürger wrote: I am currently using LDC on 64-bit-Linux if that is relevant. It is, as LDC on Windows/MSVC would use 64-bit compile-time reals. ;) Changing it to double on other platforms is trivial if you compile LDC yourself. You'll want

Re: D on AArch64 CPU

2017-05-14 Thread kinke via Digitalmars-d-learn
On Sunday, 14 May 2017 at 15:11:09 UTC, Richard Delorme wrote: On Sunday, 14 May 2017 at 15:05:08 UTC, Richard Delorme wrote: I did not touch at std.conv nor std.stdio. On LDC, the only modification concerned math.d and gammafuntion.d, missing support for 128-bit floating points. On GDC, I had

Productive vibe.d dev environment (IDE, debugger) on Linux?

2017-05-03 Thread kinke via Digitalmars-d-learn
Hey guys, can anyone recommend a more or less production-ready dev environment for vibe.d on Linux? I'm evaluating vibe.d against Phoenix (Elixir/Erlang) for a new project. Today I gave Visual Studio Code a quick shot (with LDC 1.1.1 and DMD 2.071/72/74), with Webfreak's plugins, but I'm not

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-29 Thread kinke via Digitalmars-d-learn
On Saturday, 29 April 2017 at 18:54:36 UTC, سليمان السهمي (Soulaïman Sahmi) wrote: But still, this needs to be fixed, copy pasting the name mangling is in my opinion just a hack for your specific cpp compiler on your specific platform. It can't be fixed on the D side as the Visual C++

Re: interfacing Cpp - GCC Dual ABI abi_tag in name mangling

2017-04-29 Thread kinke via Digitalmars-d-learn
On Saturday, 29 April 2017 at 18:08:16 UTC, سليمان السهمي (Soulaïman Sahmi) wrote: GCC has this attribute called abi_tag that they put on any function that returns std::string or std::list The usual workaround is compiling the C++ source with _GLIBCXX_USE_CXX11_ABI=0 for gcc >= 5.

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-28 Thread kinke via Digitalmars-d-learn
On Friday, 28 April 2017 at 18:07:49 UTC, ParticlePeter wrote: Interesting, your example corresponds to my third case, the linker error. I am on Window, building an x64 App, afaik in that case the MS Visual Studio linker is used instead of optilink. Will add your findings to the bug report.

Re: C++ Interfacing:'static' array function parameter contradiction

2017-04-28 Thread kinke via Digitalmars-d-learn
On Friday, 28 April 2017 at 15:56:17 UTC, ParticlePeter wrote: So what next? How can I interface to the cpp function? *** C++: bool cppFunc(float ()[3]) { color[0] = 1; color[1] = 2; color[2] = 3; return true; } *** D: extern(C++) bool cppFunc(ref float[3] color); void

Re: problem with std.variant rounding

2017-04-28 Thread kinke via Digitalmars-d-learn
On Friday, 28 April 2017 at 16:24:55 UTC, Suliman wrote: import std.stdio; import std.variant; void main() { Variant b = 56.051151; float x = b.coerce!float; writeln(x); } 56.0512 void main() { import core.stdc.stdio; import std.stdio; double d =

Re: multi-dimensional array whole slicing

2017-04-22 Thread kinke via Digitalmars-d-learn
On Saturday, 22 April 2017 at 20:51:46 UTC, XavierAP wrote: I can do: int[3] arr = void; arr[] = 1; But apparently I can't do: int[3][4] arr = void; arr[][] = 1; What is the best way? What am I missing? int[3][4] arr = void; (cast(int[]) arr)[] = 1; assert(arr[3][2] == 1);

Re: Windows X64 Calling conventions

2017-04-20 Thread kinke via Digitalmars-d-learn
On Thursday, 20 April 2017 at 01:16:11 UTC, Tofu Ninja wrote: My question is, why is it passed twice, both in xmm0 and rcx? The MSDN docs say floating point are passed in xmm registers, why is it also copied in into rcx? Is it necessary for anything? That is only required for variadics,

Re: C++ namespace mangling: bug or me being stupid?

2017-03-28 Thread kinke via Digitalmars-d-learn
That's a mangling compression scheme (possibly tunable via gcc options), from https://github.com/gchatelet/gcc_cpp_mangling_documentation: To save space a compression scheme is used where symbols that appears multiple times are then substituted by an item from the sequence : S_, S0_, S1_, S2_,

Re: union.sizeof

2017-03-25 Thread kinke via Digitalmars-d-learn
On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote: zabruk70 wrote: //DMD 2.073.1 and latest 2.075.0-master-972eaed //Windows 7 32-bit union Union1 { align(1): byte[5] bytes5; struct { align(1): char char1; uint int1; } } void main () { import

Re: union.sizeof

2017-03-25 Thread kinke via Digitalmars-d-learn
On Saturday, 25 March 2017 at 22:54:30 UTC, zabruk70 wrote: But for clearness... I was thinked, that align not changes SIZE, but changes LOCATION. I was thinked, that "align(X) union Union1" just force compiler to place Union1 on boundaries of X bytes... In order for all Union1 instances in

Re: questions about dub

2017-03-21 Thread kinke via Digitalmars-d-learn
On Tuesday, 21 March 2017 at 21:01:31 UTC, thorstein wrote: C:\..\AppData\Roaming\dub>dub run mir-algorithm Building package mir-algorithm in C:\..\AppData\Roaming\dub\packages\mir-algorithm-0.1.1\mir-algorithm\ Fetching mir-internal 0.0.5 (getting selected version)... Main package must have a

Re: Error: out of memory

2017-03-18 Thread kinke via Digitalmars-d-learn
The Win64 LDC releases [https://github.com/ldc-developers/ldc/releases] feature a 64-bit compiler.

Re: Cconditional expression in return statement. Bug?

2017-03-07 Thread kinke via Digitalmars-d-learn
On Tuesday, 7 March 2017 at 14:26:18 UTC, Jack Applegame wrote: I'm pretty sure this is a bug. And very bad bug. I spent several hours looking for it. What do you think? Definitely a very bad bug. It works too if you mark `fun()` as nothrow. Please file a DMD issue.

Re: RAII

2017-02-23 Thread kinke via Digitalmars-d-learn
On Thursday, 23 February 2017 at 18:46:58 UTC, kinke wrote: A constructor is just a factory function with a special name... Wrt. the special name, that's obviously extremely useful for generic templates (containers etc.).

Re: RAII

2017-02-23 Thread kinke via Digitalmars-d-learn
On Thursday, 23 February 2017 at 14:24:14 UTC, Adam D. Ruppe wrote: On Thursday, 23 February 2017 at 10:48:38 UTC, kinke wrote: That's not elegant. You need a factory function for each type containing one of these structs then. A constructor is just a factory function with a special name...

Re: RAII

2017-02-23 Thread kinke via Digitalmars-d-learn
On Thursday, 23 February 2017 at 09:57:09 UTC, ketmar wrote: Arun Chandrasekaran wrote: Is there an elegant way to achieve this in D? why not static method or free function that returns struct? due to NRVO[0] it won't even be copied. That's not elegant. You need a factory function for each

Re: Checking, whether string contains only ascii.

2017-02-22 Thread kinke via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 20:07:34 UTC, Ali Çehreli wrote: One more: bool isAscii(string s) { import std.string : representation; import std.algorithm : canFind; return !s.representation.canFind!(c => c >= 0x80); } unittest { assert(isAscii("hello world"));

Re: align(n) outside struct useless?

2017-02-20 Thread kinke via Digitalmars-d-learn
On Monday, 20 February 2017 at 22:45:09 UTC, Adam D. Ruppe wrote: I don't believe it does anything (except perhaps pad bytes again) for a stack-defined struct. LDC does respect explicit type-alignments when allocating instances on the stack. The instances are obviously padded to their full

Re: Create doc simultaneously with compilation

2017-02-20 Thread kinke via Digitalmars-d-learn
On Sunday, 19 February 2017 at 22:44:54 UTC, Satoshi wrote: Why is not possible to create documentation, compile code and generate header files simultaneously? When I pass -D and -Dd flags to ldc2 command it won't create doc until I don't pass -o- flag too. That is an LDC bug which has been

Re: Can't send messages to tid spawned in a Windows DLL. Bug?

2017-02-16 Thread kinke via Digitalmars-d-learn
On Thursday, 16 February 2017 at 12:07:40 UTC, Atila Neves wrote: This fails for me in a DLL: auto tid = spawn(); assert(tid != Tid.init); If I print out the tid, I find that its message box is null. This is odd, since according the code in std.concurrency there's nothing weird about how it

Re: Cross-compile with LDC

2017-02-08 Thread kinke via Digitalmars-d-learn
On Wednesday, 8 February 2017 at 17:21:03 UTC, Oleg B wrote: If I understand correctly with vanilla LDC I can't cross-compiling from host linux-x86_64, but with your patch I can. Right? Right. Joakim Noah has worked on LDC for Android and as far as I know provides some prebuilt compilers, a

Re: Cross-compile with LDC

2017-02-08 Thread kinke via Digitalmars-d-learn
On Wednesday, 8 February 2017 at 14:57:41 UTC, Oleg B wrote: Hello all! I want to build ldc cross compiller. I found this instruction https://wiki.dlang.org/LDC_cross-compilation_for_ARM_GNU/Linux, but I have some doubts: will it works with ldc-1.1.0? Particularly interested in the patch

Re: How do I call a C++ struct default constructor from D?

2017-02-07 Thread kinke via Digitalmars-d-learn
On Tuesday, 7 February 2017 at 10:15:09 UTC, Atila Neves wrote: I can declare a C++ struct like so: extern(C++, mynamespace) struct Foo { //... } But... I don't want to repeat the initialisation code for that struct's default constructor. I can't declare one in D because D doesn't allow

Re: "template with auto ref" experiment

2017-02-04 Thread kinke via Digitalmars-d-learn
On Saturday, 4 February 2017 at 14:33:12 UTC, Alex wrote: Having read this https://dlang.org/spec/template.html#auto-ref-parameters I tried to do something like this // Code starts here void main() { initStruct iSb; iSb.var = 3; A b = A(iSb); assert(*b.myVar ==

Re: struct: default construction or lazy initialization.

2017-02-01 Thread kinke via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 23:32:12 UTC, bitwise wrote: On Wednesday, 1 February 2017 at 23:24:27 UTC, kinke wrote: It's not that bad. D just doesn't support a default ctor for structs at all and simply initializes each instance with T.init. Your `s2` initialization is most likely seen

Re: struct: default construction or lazy initialization.

2017-02-01 Thread kinke via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 23:02:11 UTC, bitwise wrote: On Wednesday, 1 February 2017 at 01:52:40 UTC, Adam D. Ruppe wrote: On Wednesday, 1 February 2017 at 00:43:39 UTC, bitwise wrote: Container!int c; // = Container!int() -> can't do this. Can you live with Container!int c =

Re: embedding a library in Windows

2017-01-30 Thread kinke via Digitalmars-d-learn
You'll probably be more successful with a static .lib library generated with the MS compiler (Visual Studio). I'd suggest compiling sqlite yourself and then using DMD with the `-m32mscoff` switch (32-bit) or `-m64` for 64-bit. Google is your friend in case you don't know how to build a static

Re: General performance tips

2017-01-23 Thread kinke via Digitalmars-d-learn
On Monday, 23 January 2017 at 12:13:30 UTC, albert-j wrote: There's not much object creation going on there, mostly loops over arrays, so I assume GC is not an issue. When passing arrays around, beware that static arrays are value types in D and are copied unless passed by reference.

Re: Printing a floats in maximum precision

2017-01-18 Thread kinke via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:36:39 UTC, Nicholas Wilson wrote: Alternatively use %a to print in hex to verify exact bit patterns. +1, if it doesn't have to be human-readable.

Re: Initializing floating point types with explicit mantisa and exponent

2017-01-17 Thread kinke via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 00:08:24 UTC, Nordlöw wrote: How do I best initialize a D double to an exact mantissa and exponent representation? I'm specifically interested in 2^^i for all i in [min_exp, max_exp] If it doesn't have to be D ;), it can be as simple as

Re: Thread will get garbage collected?

2017-01-16 Thread kinke via Digitalmars-d-learn
On Monday, 16 January 2017 at 22:08:56 UTC, JN wrote: Am I correctly understanding, that after going out of scope, it's possible for GC to destroy my thread before the file finishes loading? How to prevent GC from destroying my thread before it finishes and make sure the file is loaded

Re: Querying parameter passing semantics for `auto ref const` variables

2017-01-15 Thread kinke via Digitalmars-d-learn
On Sunday, 15 January 2017 at 14:33:25 UTC, Nordlöw wrote: A call to `isRef!T` inside the function `f` is always `false` for `l-value` and `r-value` passing. According to https://dlang.org/spec/template.html#auto-ref-parameters, it should be `__traits(isRef, x)`.

Re: Hopefully a simple question...

2017-01-13 Thread kinke via Digitalmars-d-learn
On Friday, 13 January 2017 at 16:56:43 UTC, WhatMeWorry wrote: A vec and scalar can't be added together. So why (or how) is the glm code working? The C++ source disagrees: https://github.com/g-truc/glm/blob/master/glm/detail/type_vec2.hpp#L219 It works via operator overloading, and adding a

Re: returning struct, destructor

2016-12-21 Thread kinke via Digitalmars-d-learn
On Wednesday, 21 December 2016 at 18:02:54 UTC, bauss wrote: It removes an unnecessary allocation for the returning copy of the struct, as the return value is never used. Hence why it's pointless that it would be compiled anyway. That's incorrect, it doesn't have anything to do with the

Re: returning struct, destructor

2016-12-21 Thread kinke via Digitalmars-d-learn
On Wednesday, 21 December 2016 at 15:01:20 UTC, Eugene Wissner wrote: On Wednesday, 21 December 2016 at 14:15:06 UTC, John C wrote: On Wednesday, 21 December 2016 at 11:45:18 UTC, Eugene Wissner wrote: This prints 3 times "Destruct" with dmd 0.072.1. If I remove the if block, it prints

Re: BetterC classes

2016-12-20 Thread kinke via Digitalmars-d-learn
On Tuesday, 20 December 2016 at 13:30:54 UTC, Kagamin wrote: On Friday, 16 December 2016 at 18:29:33 UTC, Ilya Yaroshenko wrote: Undefined symbols for architecture x86_64: "__D14TypeInfo_Class6__vtblZ", referenced from: __D8cppclass2Hw7__ClassZ in cppclass-7ed89bd.o By using typeid

Re: Returning structs from COM

2016-12-19 Thread kinke via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=16987 https://github.com/ldc-developers/ldc/issues/1935

Re: Returning structs from COM

2016-12-19 Thread kinke via Digitalmars-d-learn
On Monday, 19 December 2016 at 09:49:13 UTC, kinke wrote: That's rather interesting. The COM function really seems to return the struct directly, not returning an HRESULT and setting some output pointee as most COM functions I've seen so far. According to the Win64 ABI, the returned

Re: Returning structs from COM

2016-12-19 Thread kinke via Digitalmars-d-learn
On Monday, 19 December 2016 at 12:23:46 UTC, evilrat wrote: x64 still has messed up 'this'(both dmd and ldc, not tested with gdc) Please file an LDC issue then, as I'm pretty sure it works for regular (non-COM) C++ classes.

Re: Returning structs from COM

2016-12-19 Thread kinke via Digitalmars-d-learn
On Saturday, 3 December 2016 at 09:51:00 UTC, John C wrote: Some DirectX methods return structs by value, but when I try calling them I either get garbage or an access violation. Usually COM methods return structs by pointer as a parameter, but these are returning the struct as the actual

Re: meaning of "auto ref const"?

2016-12-18 Thread kinke via Digitalmars-d-learn
On Sunday, 18 December 2016 at 13:14:08 UTC, Picaud Vincent wrote: bool opEquals()(auto ref const BigInt y) const pure @nogc { return sign == y.sign && y.data == data; } my problem is that I do not understand the role/meaning of "auto" in this context. See

<    1   2   3   4   >