Re: How to avoid multiple spelling `import`

2015-06-17 Thread Joy-Killer via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote: mixin template include(w...) { mixin _include!(w.length - 1, w); } mixin template _include(long N, i...) { mixin("import " ~ i[N] ~ ";"); mixin _include!(N - 1, i); } mixin template _include(long N : 0, i...) { mixi

Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread Atila Neves via Digitalmars-d-learn
I thought it was because I was weird and I use gold as my linker, but ld.bfd produced the same results. The most I could find in bug reports was someone complaining it used to work but the consensus was that it never did? Atila

Re: Embedding dll in a D project

2015-06-17 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 17:32:33 UTC, CallToDuty wrote: On Tuesday, 16 June 2015 at 16:57:52 UTC, John Colvin wrote: On Tuesday, 16 June 2015 at 16:42:31 UTC, CallToDuty wrote: Is it possible to embed a dll file within dub project? and if yes, how? Have you tried just putting it in the ro

Re: Calling a cpp function from d

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23, nul

Re: Calling a cpp function from d

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23, nul

Re: exclude current directory from search path in dmd ?

2015-06-17 Thread Liran Zvibel via Digitalmars-d-learn
On Monday, 8 June 2015 at 04:08:55 UTC, Adam D. Ruppe wrote: The easiest way is to not use search paths, and instead pass all the modules you want compiled to the compiler directly. Then it will look for the module name declaration instead of the directory/filename layout. I think that this s

Re: Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread Dicebot via Digitalmars-d-learn
druntime has never had support for file/line info in traces on Linux AFAIR gdb usually saves the day

Re: Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 11:07:29 UTC, weaselcat wrote: On Wednesday, 17 June 2015 at 07:53:16 UTC, Atila Neves wrote: I thought it was because I was weird and I use gold as my linker, but ld.bfd produced the same results. The most I could find in bug reports was someone complaining it use

Re: Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread weaselcat via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 07:53:16 UTC, Atila Neves wrote: I thought it was because I was weird and I use gold as my linker, but ld.bfd produced the same results. The most I could find in bug reports was someone complaining it used to work but the consensus was that it never did? Atila

Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I don't see a way how I could access (cast) the raw data of a std.container.array to forward it to these wrapper functions. std.array(R

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:04:28 UTC, ParticlePeter wrote: I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I don't see a way how I could access (cast) the raw data of a std.cont

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:07:11 UTC, Alex Parrill wrote: On Wednesday, 17 June 2015 at 13:04:28 UTC, ParticlePeter wrote: I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I don'

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:04:28 UTC, ParticlePeter wrote: I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I don't see a way how I could access (cast) the raw data of a std.cont

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread Kagamin via Digitalmars-d-learn
(&arr.front())[0 .. arr.length] ?

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:31:21 UTC, Marc Schütz wrote: On Wednesday, 17 June 2015 at 13:04:28 UTC, ParticlePeter wrote: I use wrapper functions taking void[] arrays to forward them comfortably to mentioned OpenGL functions. This works with static and dynamic build in arrays, but I don't

Re: Convert std.container.array to void[] and/or pass to OpenGL functions like glBuffer(Sub)Data

2015-06-17 Thread ParticlePeter via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 13:58:09 UTC, Kagamin wrote: (&arr.front())[0 .. arr.length] ? Yes, this works, nice, thanks :-)

Re: Does anyone get line numbers in stack traces on Linux?

2015-06-17 Thread ketmar via Digitalmars-d-learn
i have that. with GCD. ;-) signature.asc Description: PGP signature

Re: Defining constant values in struct

2015-06-17 Thread ketmar via Digitalmars-d-learn
On Wed, 17 Jun 2015 09:49:56 +0900, Mike Parker wrote: > On 6/17/2015 6:17 AM, tcak wrote: >> As far as I known, when I define a string with enum and it is used at >> different parts of code, that string is repeated again and again in >> executable file instead of passing a pointer to string. So,

Re: Are stack+heap classes possible in D?

2015-06-17 Thread ketmar via Digitalmars-d-learn
On Wed, 17 Jun 2015 06:02:46 +, WhatMeWorry wrote: > I guess the question would be why would one want a struct on the heap > and a class on the stack? Performance reasons? struct on the heap: some containers, for example, doing their own memory management. class on the stack: guaranteed de

best way to interface D code to Excel

2015-06-17 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. Any thoughts on the best way to write D functions that I can call from Excel? I am completely unfamiliar with Windows programming and COM (last time I wrote this kind of thing was in the mid-90s I think using xloper and C). The easiest way for now seems to be via pyxll and pyd. Wrap th

Base type for arrays

2015-06-17 Thread jmh530 via Digitalmars-d-learn
I want to write a function template that works for any array of a particular type, but not the base type, so real[], real[][], etc, but not real. I was using ForeachType to do some testing, but it doesn't really get the base type. It just takes one of the [] off and returns the remaining type (

Re: Base type for arrays

2015-06-17 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 19:53:07 UTC, jmh530 wrote: I want to write a function template that works for any array of a particular type, but not the base type, so real[], real[][], etc, but not real. I was using ForeachType to do some testing, but it doesn't really get the base type. It jus

Re: Base type for arrays

2015-06-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:06:54 UTC, Alex Parrill wrote: Try: void foo(T)(T[] arg) { // In here, T should be the element type, and T[] the array type. } Not a general solution, but you mentioned that you wanted this for a function parameter. I don't think this works for multi-

Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread Dan via Digitalmars-d-learn
hi I'm using those imports: import core.runtime; import core.sys.windows.windows; when I call GetWindowTextW DMD compiler complains! (error:undefined identifier) any solution?

Re: Base type for arrays

2015-06-17 Thread Namespace via Digitalmars-d-learn
import std.stdio; template BaseTypeOf(T) { static if (is(T : U[], U)) alias BaseTypeOf = BaseTypeOf!(U); else alias BaseTypeOf = T; } void foo(T : U[], U)(T arr) if (is(BaseTypeOf!(U) == real)) { } void main() { //real _x; real[2] x;

Re: Base type for arrays

2015-06-17 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:20:29 UTC, jmh530 wrote: On Wednesday, 17 June 2015 at 20:06:54 UTC, Alex Parrill wrote: Try: void foo(T)(T[] arg) { // In here, T should be the element type, and T[] the array type. } Not a general solution, but you mentioned that you wanted this for

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread Dan via Digitalmars-d-learn
I'm new to Dlang and I have no Idea whats wrong with this code! wchar[260] buffer; HWND hWindow = GetForegroundWindow(); GetWindowTextW(hWindow, buffer, sizeof(title)); <-- Problem here

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread Dan via Digitalmars-d-learn
GetWindowTextW(hWindow, buffer, sizeof(title)); <-- Problem here please Ignore the sizeof(title) parameter, I copied that from c++ equivalent code :D

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:40:02 UTC, Dan wrote: I'm new to Dlang and I have no Idea whats wrong with this code! wchar[260] buffer; HWND hWindow = GetForegroundWindow(); GetWindowTextW(hWindow, buffer, sizeof(title)); <-- Problem here The compiler is complaining it can't find an identifi

Re: Base type for arrays

2015-06-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:33:11 UTC, Namespace wrote: import std.stdio; template BaseTypeOf(T) { static if (is(T : U[], U)) alias BaseTypeOf = BaseTypeOf!(U); else alias BaseTypeOf = T; } void foo(T : U[], U)(T arr) if (is(BaseTypeOf!(U) == real)) {

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread Dan via Digitalmars-d-learn
thank you John it worked :) do I always need do the same for all windows API?

Re: Base type for arrays

2015-06-17 Thread Namespace via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:58:10 UTC, jmh530 wrote: On Wednesday, 17 June 2015 at 20:33:11 UTC, Namespace wrote: import std.stdio; template BaseTypeOf(T) { static if (is(T : U[], U)) alias BaseTypeOf = BaseTypeOf!(U); else alias BaseTypeOf = T; } void foo(T :

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:50:27 UTC, John Chapman wrote: wchar[MAX_PATH] buffer; int length = GetWindowTextW(GetForegroundWindow(), buffer.ptr, buffer.length); Don't know why I used MAX_PATH there. You should probably dynamically allocate a buffer based on GetWindowTextLengthW.

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 21:00:55 UTC, Dan wrote: thank you John it worked :) do I always need do the same for all windows API? For most Win32 API functions, yes. Although there are some more complete headers on Github (for example, https://github.com/rikkimax/WindowsAPI).

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread Dan via Digitalmars-d-learn
thank you so much John :)

Re: Base type for arrays

2015-06-17 Thread Meta via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 19:53:07 UTC, jmh530 wrote: I want to write a function template that works for any array of a particular type, but not the base type, so real[], real[][], etc, but not real. I was using ForeachType to do some testing, but it doesn't really get the base type. It jus