Re: returning struct, destructor

2016-12-21 Thread John C via Digitalmars-d-learn
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 "Destruct" only 2 times - the behavior I'm expecting. Why? Possibly to do with named return value optimisation.

Re: Proper generic way to get the hash of something?

2016-12-04 Thread John C via Digitalmars-d-learn
On Sunday, 4 December 2016 at 06:51:24 UTC, Tofu Ninja wrote: So what is the proper way to get the hash of something now? This question came up a few days ago: http://forum.dlang.org/post/o1igoc$21ma$1...@digitalmars.com

Returning structs from COM

2016-12-03 Thread John C via Digitalmars-d-learn
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 return value, as in this definition: extern(Windows): stru

Re: problem with isnan

2016-11-11 Thread John C via Digitalmars-d-learn
On Friday, 11 November 2016 at 20:55:52 UTC, Charles Hixson wrote: Thank you. Unfortunately: importstd.math; ... assert(isNan (c.curActivation), "cell has unexpected curActivation: %s".format(c.curActivation)); yields: cell.d(292): Error: undefined identifier 'isNan', did

Re: Error 42 When Trying to Interop with a C# Libary

2016-11-05 Thread John C via Digitalmars-d-learn
On Saturday, 5 November 2016 at 21:02:14 UTC, Adam D. Ruppe wrote: coff2omf works with .obj files Well, that's not what the docs say! http://www.digitalmars.com/ctg/coff2omf.html "The input files can be either object files (.obj) or library files (.lib)" Apparently you have to convert t

Re: Error 42 When Trying to Interop with a C# Libary

2016-11-05 Thread John C via Digitalmars-d-learn
On Saturday, 5 November 2016 at 16:13:18 UTC, Sarcross wrote: If you're wondering, I did use the COFF2OMF tool on the library I got from the C# code, which is why in WordFileParser.d you'll see "pragma(lib, "Parser2")". I have never had success trying to link with a lib file converted by COFF

Re: How to get sqlite3.lib x64?

2016-10-24 Thread John C via Digitalmars-d-learn
On Monday, 24 October 2016 at 05:43:00 UTC, Andre Pany wrote: Hi, I try to get sqlite3.lib for 64 Bit windows os. I tried implib with the def file and the 64 Bit dll: implib sqlite3_implib.lib sqlite3.def /system -> App crash (Windows 10) With the dll file defined: implib sqlite3_implib.lib sq

Re: How to correctly display accented characters at the Windows prompt?

2016-10-10 Thread John C via Digitalmars-d-learn
On Monday, 10 October 2016 at 14:14:08 UTC, Cleverson Casarin Uliana wrote: Hello, when I run a compiled Windows executable at the console, letters outside the ascii range such as ç and ã do not display propperly. Is there any d function to change the console code page on the fly? My Windows co

Re: Basic sounds' playing

2016-10-08 Thread John C via Digitalmars-d-learn
On Saturday, 8 October 2016 at 13:35:57 UTC, Cleverson Casarin Uliana wrote: Thank you Vadim and John, the PlaySound function is enough for now. I'm not yet developing an app, just experimenting with some exercises. The wasapi library seems interesting, does it also implement a playSound-like

Re: Basic sounds' playing

2016-10-08 Thread John C via Digitalmars-d-learn
On Saturday, 8 October 2016 at 01:00:20 UTC, Cleverson Casarin Uliana wrote: Hello all, starting to learn d, apreciating it so far. I'd like to play/stop wave sound files assynchronously on Windows. Can I get a module for that by installing a particular compiler, or is there any package for it

Re: Convert type tuple to array?

2016-10-05 Thread John C via Digitalmars-d-learn
On Wednesday, 5 October 2016 at 11:46:14 UTC, Adam D. Ruppe wrote: On Wednesday, 5 October 2016 at 11:43:12 UTC, John C wrote: Is there a way to convert something like AliasSeq!(int, int, int) to an int[] - the opposite of aliasSeqOf? If it is a legal array (matching types), just put

Convert type tuple to array?

2016-10-05 Thread John C via Digitalmars-d-learn
Is there a way to convert something like AliasSeq!(int, int, int) to an int[] - the opposite of aliasSeqOf?

Re: Member not accessible in delegate body

2016-09-23 Thread John C via Digitalmars-d-learn
On Friday, 23 September 2016 at 18:20:24 UTC, Martin Nowak wrote: Please file a bug report issues.dlang.org, shouldn't be difficult to fix. Done: https://issues.dlang.org/show_bug.cgi?id=16531

Member not accessible in delegate body

2016-09-23 Thread John C via Digitalmars-d-learn
If I try to call the protected method of a superclass from inside the body of a delegate, the compiler won't allow it. void layoutTransaction(Control c, void delegate() action) { // do stuff action(); // do more stuff } class Control { protected void onTextChanged() {} } class Label :

Re: CRTP in D?

2009-08-20 Thread John C
div0 Wrote: > > > While we're on the subject, is it possible to mixin in a tuple? > Doesn't seem like you can... > > class C(M...) { > mixin M; > } > > Doesn't work. import std.typetuple; class C(M...) { mixin TypeTuple!(M); }

Re: Enum name convention consistency

2009-08-19 Thread John C
Sam Hu wrote: From std.range: enum StoppingPolicy { /// Stop when the shortest range is exhausted shortest, /// Stop when the longest range is exhausted longest, /// Require that all ranges are equal requireSameLength, } From std.thread:( phobos webpage) enum State; A f

Re: win32 capCreateCaptureWindow problem

2009-08-14 Thread John C
Sam Hu wrote: John C Wrote: Sam Hu Wrote: John C Wrote: Ivan Boritsky wrote: i work on a win32 application. i try to access my web camera. when i use this api funtion; capCreateCaptureWindow("cam", WS_VISIBLE + WS_CHILD, 10, 10,266, 252, hWnd, 0); That should be: WS_VISIBLE

Re: win32 capCreateCaptureWindow problem

2009-08-13 Thread John C
Sam Hu Wrote: > John C Wrote: > > > Ivan Boritsky wrote: > > > i work on a win32 application. i try to access my web camera. > > > when i use this api funtion; > > > capCreateCaptureWindow("cam", WS_VISIBLE + WS_CHILD, 10, 10,266, 252, &g

Re: win32 capCreateCaptureWindow problem

2009-08-12 Thread John C
Ivan Boritsky wrote: i work on a win32 application. i try to access my web camera. when i use this api funtion; capCreateCaptureWindow("cam", WS_VISIBLE + WS_CHILD, 10, 10,266, 252, hWnd, 0); That should be: WS_VISIBLE | WS_CHILD. i get this error: Error: undefined identifier capCreateCaptur

Re: D2 phobos std.date question

2009-07-15 Thread John C
Sam Hu Wrote: > Stewart Gordon Wrote: > > > > > Read the source of std.date and see for yourself. If it's getting it > > wrong, it suggests either your system is misconfigured or you're using > > it wrongly. But since you still haven't posted your code, I still can't > > comment further. >

Re: remove a file with tango

2009-07-14 Thread John C
John Cahn Wrote: > anyone know how to delete/remove a file with tango. thanks in advance. http://www.dsource.org/projects/tango/wiki/ChapterIoFileSystem

Re: Object.factory create instance failed?

2009-06-26 Thread John C
Sam Hu Wrote: > John C Wrote: > > > Object.factory requires a fully qualified class name, so if class Dog > > resides in module animals, call Object.factory("animals.Dog"). > > It works now.Great!Thanks so much! > > But...may I ask how do you know that

Re: Object.factory create instance failed?

2009-06-25 Thread John C
Sam Hu Wrote: > > In below code snippet: > > class Dog > { > public void bark(){} > } > int main(string[] args) > { > auto obj=Object.factory("Dog"); > Dog doggie=cast(Dog)obj; > doggie.bark; > > return 0; > } > > Compiled successfully but failed when run: > Object.Error:Access Violation. > >

Re: Using to! ?

2009-06-17 Thread John C
unknown Wrote: > Hi, > > Given the example below: > string str = "1 2 3 4 5 6"; > double[] numbers = to!(double[])(split(str)); > writefln(to!string(numbers)); > > I get [1, 2, 3, 4, 5, 6] which is okay. > > How do I output it with different separators? > > What I would like to get is [ 1 2 3

Porting 1.x libraries to 2.x

2009-06-10 Thread John C
What strategies do library authors have for maintaining two versions of a their code - one for D 1.0 and another for 2.0? When they make changes to one version, do they manually copy them into the other branch? Or is there a way of automating the process? Version blocks don't seem to help much.

Re: A couple of questions

2009-05-13 Thread John C
Sam Hu Wrote: > Thanks.The construct is clear now. > > Still leaves Q1,that is ,the *if* expression after the template definition,I > want to learn more about the usage,where can I find more information? It is in the spec: http://www.digitalmars.com/d/2.0/template.html#Constraint

Re: 3 variant questions

2009-05-12 Thread John C
Saaa Wrote: > > > > import std.stdarg; > > > > assert( _arguments[0] is typeid(int*) ); > > auto arg = va_arg!(int*)(_argptr); > > *arg = 10; > > > > Probably. > > > > -- Daniel > > Calling the following returns an Access Violation Error after > correctly writing the two lines. > > void main()

Re: D2 string conversion

2009-05-10 Thread John C
Sam Hu Wrote: > Hi Sivo & John, > > Thank you very much!!!The two versions all work. > > But I am a bit confused with the key word *in* in both versions. It's simple, really. Strings are immutable in D2. And "in" is equivalent to "immutable". By the way, best to use wstring (for UTF-16) or st

Re: D2 string conversion

2009-05-09 Thread John C
Sam Hu Wrote: > Hello, > > In D2 I tried to write a simple function which wrapps WIN32 API > MessageBoxW,with which I can handle wide characters like Chinese .Below is my > try: > > import std.string; > import std.conv; > import std.c.windows.windows; > > extern(Windows)int MessageBoxW(HWND,L

Re: Resource availability: fonts

2009-05-06 Thread John C
Tyro[a.c.edwards] Wrote: > When I do this, how do I ensure that the program is able to locate the > font after extraction without "installing" it? > I think AddFontResource from the SDK will do that. http://msdn.microsoft.com/en-us/library/dd183326(VS.85).aspx

Re: convert *void to void[]

2009-05-06 Thread John C
gabrielsylar Wrote: > can anybody please tell me how to properly convert from void* to void[] > as the code below? > > void[] get_bytes(int n) { return sqlite3_column_blob(stmt, n); } return sqlite3_column_blob(stmt, n)[0 .. n];

Re: line drawing package?

2009-05-03 Thread John C
BCS Wrote: > I find my self in need of a line drawing package. I need to pop a window > and draw lines and points. Text would be nice but I can live without it. > Most importantly, I need something that is dirt simple to get running. I > don't have time to dink around with libs (if I did have t

Re: convert and assign to the BSTR char

2009-04-18 Thread John C
new Wrote: > hi, > > how does one convert char[] to BSTR and back? i am looking to use a dll that > contains function such as > > BSTR tester = gettest(BSTR *in, BSTR in1); > > any help is appreciated. wchar* bstr = SysAllocString(std.utf.toUTF16z(s)); and char[] s = std.utf.toUTF8(bstr

Re: Template function : use the array's one !

2009-02-18 Thread John C
TSalm Wrote: > Hello, > > I'm searching to have a generic comparator function. > > I done this : > > /* CODE */ > import tango.io.Stdout; > > /*** > * Not for arrays > ***/ > int compare(T)(T o1,T o2) > { >static if ( is( T bar == class ) || is( T

Re: Getting environment variables?

2008-11-24 Thread John C
novice2 Wrote: > i am afraid that windows API named *W works with UCS2 string. > but D wchar[] is UTF-16. Wrong - Windows has used UTF-16 as native since Windows 2000.