WindowsAPI Binding - Linker Errors

2011-06-13 Thread Loopback
Hello! I've been test programming win32 applications recently, and since the phobos win32 library is so limited, I decided to download and test the WindowsAPI Binding (http://www.dsource.org/projects/bindings/wiki/WindowsApi). Using the latest snapshot (as of this writing) I receive the

Undefined function, even though imported

2011-06-13 Thread Loopback
Hi! Let me begin by saying, I'm sorry if this is caused of some obvious error but since I am new to D, I am not aware of all the tricks and treats it offers. I am working with the WindowsAPI binding at dsource.org (though I do not believe this is related to the binding itself). However, in

Re: Undefined function, even though imported

2011-06-13 Thread Loopback
Thanks for your answer! Seems like supplying with the file location solved the problem, though I still wonder about one thing. The imported module is located in c:/d/dmd2/import/win32/windef.d and I have used this command line to the DMD compiler: -Ic:/d/dmd2/import/. Shouldn't the

Re: Undefined function, even though imported

2011-06-13 Thread Loopback
On 2011-06-13 23:51, Jonathan M Davis wrote: On 2011-06-13 14:44, Loopback wrote: Thanks for your answer! Seems like supplying with the file location solved the problem, though I still wonder about one thing. The imported module is located in c:/d/dmd2/import/win32/windef.d and I have used

Re: Undefined function, even though imported

2011-06-13 Thread Loopback
Thanks for all the answers! Seems like rdmd did the trick. I don't see why this isn't built in to dmd though, or does it cause overhead when you are using rdmd? Benefits, Drawbacks? I've also stumbled upon an additional error with the win32 DirectX bindings, but this seems D related actually.

Re: Undefined function, even though imported

2011-06-14 Thread Loopback
Well, I solved the linker error by specifying imports in the .def file. The pathetic thing was that the def file was invalid just because I had a newline, or at least it worked without it. So my final .def file looks like this: EXETYPE NT SUBSYSTEM WINDOWS IMPORTS _Direct3DCreate9@4 =

Convert const(GUID)* to GUID*

2011-06-25 Thread Loopback
Hello! I've recently been working with DirectInput using the win32 API Binding at dsource.org. This wrapper has been working perfectly fine until I started using GUID constants defined in win32.directx.dinput8. The directx function DirectInput8Create takes these parameters: HRESULT

Win32 Application Error

2011-06-28 Thread Loopback
Hi! I've recently been using D to program win32 executables. On the official D site (d-programming-language.org) there is a template of how a basic win32 executable is supposed to be. In this template you are supposed to initialize and terminate the D runtime. If I understand correctly this

Re: Win32 Application Error

2011-06-28 Thread Loopback
Thank you for your reply! I do not use multi-threading so it is not related to that. Though I do have located the error. It seems as if the application only hangs/delays application exit, when I load a texture file with DirectX. To be specific, the function in this case is

Re: Win32 Application Error

2011-06-28 Thread Loopback
One more thing, would it perhaps help if I supplied a delegate to the terminate function, since that may output debug messages? I would gladly try it but I am not sure how this supplied delegate is supposed to be. Also want to mention that the initialize functions returns successfully.

Re: Win32 Application Error

2011-06-29 Thread Loopback
Please ignore. Sadly I hadn't learned the D reference just enough and I did not realize that the base destructor of a class is still called.

Operator Overloading and boilerplate code

2011-07-02 Thread Loopback
Hi! I've made a two dimensional vector structure (x, y) which is very primitive, the only real thing that I want to do with this structure is support for nearly all operators and support for D3DXVECTOR2 and POINT structures. While writing this structure the boilerplate code has steadily

Re: Operator Overloading and boilerplate code

2011-07-03 Thread Loopback
Thank you! How excellent you handled the boilerplate code. Works perfectly fine as well, except one little thing. I cannot declare this DVECTOR2 structure immutable because the compiler complains saying this: Error: variable __ctmp1485 cannot be read at compile time Error: cannot evaluate

Re: Operator Overloading and boilerplate code

2011-07-04 Thread Loopback
I've researched a bit though I still haven't come up with a solution. Since the problem lies within (the most simple) constructor, I tried to modify it for another outcome. If I supplied a generic parameter to the pre-constructor the Cannot evaluate at compile time message disappeared but two new

Re: Operator Overloading and boilerplate code

2011-07-05 Thread Loopback
On 2011-07-05 03:11, Ali Çehreli wrote: On Tue, 05 Jul 2011 02:44:03 +0200, Loopback wrote: I've researched a bit though I still haven't come up with a solution. Since the problem lies within (the most simple) constructor, I tried to modify it for another outcome. If I supplied a generic

Re: Operator Overloading and boilerplate code

2011-07-05 Thread Loopback
On 2011-07-05 18:05, Ali Çehreli wrote: I don't want to look like brushing off the problem but having many constructors make the code complicated. For example, it may be confusing which constructor gets called here: auto d = DVECTOR2(1.5); That might be true. I just did what felt most

Constructor call must be in a constructor

2011-07-06 Thread Loopback
Hi! While implementing and overloading several different operators for my structure I've got stuck with an error. As noticed in the attachment, in my opBinaryRight function I mimic the opBinary (left) operator by instantiating the structure itself to avoid implementing duplicates of the binary

Re: Float Comparison Returns False

2011-07-07 Thread Loopback
On 2011-07-07 20:35, Steven Schveighoffer wrote: On Thu, 07 Jul 2011 14:19:05 -0400, Loopback elliott.darf...@gmail.com wrote: Hello! I've been programming some miscellaneous code and got stuck in an odd case. While comparing floats, two obviously identical values return false in comparison

Re: Float Comparison Returns False

2011-07-07 Thread Loopback
On 2011-07-08 02:28, bearophile wrote: Loopback: I do want to ask though what an alternative would be in this case, to compare the two different values. You mentioned something about epsilons but I have no experience within this field. I would really appreciate an example or something similar

Re: Float Comparison Returns False

2011-07-09 Thread Loopback
On 2011-07-08 04:31, Loopback wrote: On 2011-07-08 02:28, bearophile wrote: Loopback: I do want to ask though what an alternative would be in this case, to compare the two different values. You mentioned something about epsilons but I have no experience within this field. I would really

Re: String Appender Fails (Memory Allocation Failure)

2011-07-13 Thread Loopback
On 2011-07-14 01:11, Loopback wrote: Hello! I've been working on a project where I had to do all memory handling explicitly because no destructors were called. When I got too tired of the explicit memory handling I decided to trace what was causing this error. After hours of code stripping I

String Appender Fails (Memory Allocation Failure)

2011-07-13 Thread Loopback
Hello! I've been working on a project where I had to do all memory handling explicitly because no destructors were called. When I got too tired of the explicit memory handling I decided to trace what was causing this error. After hours of code stripping I had gotten myself a small concrete

Re: String Appender Fails (Memory Allocation Failure)

2011-07-13 Thread Loopback
On 2011-07-14 01:17, David Nadlinger wrote: Currently, no memory can be allocated at all during garbage collection runs, which is where destructors are usually called. David That explains it. Do you know when this feature will be available, if at all? Here is another interesting case, where

Re: Problems with static linking of c libraries

2011-07-14 Thread Loopback
You need to convert the libraries to OMF format from COFF. These are some tools which can do this: Coffimplib: http://www.digitalmars.com/ctg/coffimplib.html Coff2OMF: http://www.digitalmars.com/ctg/coff2omf.html ObjConv: http://www.agner.org/optimize/objconv.zip

Re: Problems with static linking of c libraries

2011-07-14 Thread Loopback
On 2011-07-14 17:06, Danny Arends wrote: Wow THANX, Using the COFF2OMF tool at least got me a step further, now it finds and accepts the lib files, however, it now fails with the following error: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved.

Re: String Appender Fails (Memory Allocation Failure)

2011-07-14 Thread Loopback
Anybody got an idea?

Static Destructors called early

2011-07-15 Thread Loopback
Hi! I'm having a pretty big mess just because my static destructors are called before my non-static destructors. Now my question is; is this related only to win32 applications where one uses runtime.terminate? The problem is that I am using external libraries, and in one of these cases you

Calling D from C++

2011-07-17 Thread Loopback
Hello! As of my understanding you can write usable c libraries in D by using extern(C). The problem is that I haven't found any other threads asking the same question about C++ (since extern for c++ exists as well). So I have two questions, is it possible to write a dll in D usable in c++ code,

Re: Calling D from C++

2011-07-17 Thread Loopback
On 2011-07-17 21:45, Loopback wrote: Hello! As of my understanding you can write usable c libraries in D by using extern(C). The problem is that I haven't found any other threads asking the same question about C++ (since extern for c++ exists as well). So I have two questions, is it possible

Re: Calling D from C++

2011-07-18 Thread Loopback
On 2011-07-17 22:51, Johann MacDonagh wrote: On 7/17/2011 3:53 PM, Loopback wrote: On 2011-07-17 21:45, Loopback wrote: Hello! As of my understanding you can write usable c libraries in D by using extern(C). The problem is that I haven't found any other threads asking the same question about

Re: Calling D from C++

2011-07-18 Thread Loopback
On 2011-07-18 21:59, Andrej Mitrovic wrote: import core.dll_helper; is outdated, use import core.sys.windows.dll; And also import core.runtime; Are there any examples covering these new modules, or are the procedure the same?

Re: Calling D from C++

2011-07-18 Thread Loopback
with the code I copy pasted in the other message. Loopback, do you have Visual Studio on your dev box? If so you should take a look at VisualD: http://www.dsource.org/projects/visuald Let us know if you're not able to compile a D DLL. Thanks for all of your replies! It seems as if the problem

Re: Calling D from C++

2011-07-18 Thread Loopback
On 2011-07-19 04:40, Andrej Mitrovic wrote: You have several problems. extern(C++) only specifies the calling convention, not the visibility of the symbol. To export the symbol, list it in a .def file or mark the function with export in the module itself, ala: export extern(C++) void

Re: Calling D from C++

2011-07-19 Thread Loopback
On 2011-07-19 05:46, Johann MacDonagh wrote: What is the best method to accomplish this, and are there any limitations with this method (do I have to allocate the class with malloc instead etc.)? Your C++ class Base is not compatible with your D Foo class. The v-tables are not guaranteed to

Re: Calling D from C++

2011-07-19 Thread Loopback
On 2011-07-19 12:39, Loopback wrote: On 2011-07-19 05:46, Johann MacDonagh wrote: What is the best method to accomplish this, and are there any limitations with this method (do I have to allocate the class with malloc instead etc.)? Your C++ class Base is not compatible with your D Foo class