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

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

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

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

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

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

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: 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 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 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: 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, using

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: 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 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: 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

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: 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 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 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

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

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

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...) {

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,

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

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

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: 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,

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

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.

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

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

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

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: 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: Are stack+heap classes possible in D?

2015-06-17 Thread WhatMeWorry via Digitalmars-d-learn
On Sunday, 14 June 2015 at 01:31:25 UTC, Adam D. Ruppe wrote: On Sunday, 14 June 2015 at 00:52:20 UTC, FujiBar wrote: I have read that in D structs are always allocated on the stack while classes are always allocated on the heap. That's not true; it is a really common misconception. Putting