March 03, 2011
On 02.03.2011 18:24, Denis Koroskin wrote:
> On Tue, 01 Mar 2011 23:01:21 +0300, simendsjo
> <simen.endsjo@pandavre.com> wrote:
>
>> On 28.02.2011 20:24, Denis Koroskin wrote:
>>> On Mon, 28 Feb 2011 22:04:44 +0300, simendsjo
>>> <simen.endsjo@pandavre.com> wrote:
>>>
>>>> On 28.02.2011 18:52, simendsjo wrote:
>>>>>
>>>>> // ERROR
>>>>> auto res = mysql_library_init(0, null, null);
>>>>>
>>>>> auto cn = mysql_init(null);
>>>>> auto oldcn = cn;
>>>>>
>>>>> writeln(mysql_errno(cn));
>>>>> assert(cn == oldcn); // when the last assert is active, the above line
>>>>> changes cn and thus fails.
>>>>>
>>>>> auto err = mysql_errno(cn);
>>>>> assert(cn == oldcn);
>>>>
>>>> Btw, if I don't use writeln it doesn't fail..
>>>
>>> I think you have a bug at line 42.
>>>
>>> On a serious note, it might have helped if you'd attached source code,
>>> or at least binaries.
>>
>> Hmmm.. Seems my post last night didn't get through..
>> Here's the code and necessary libraries: http://share1t.com/4xgt2l
>
> What appears to be an error here is in fact an Access Violation at
> mysql_close.
>
> Here is a reduced test-case:
>
> import mysql;
>
> void main()
> {
> auto res = mysql_library_init(0, null, null);
> auto cn = mysql_init(null);
> mysql_close(cn);
> }
>
>
> Then I decided to check whether it is D's fault or not by porting this
> short program to C. Here is what I got:
>
> // mysql.c
> int mysql_server_init(int argc, char **argv, char **groups);
> struct MYSQL* mysql_init(struct MYSQL*);
> void mysql_close(struct MYSQL*);
>
> #define mysql_library_init mysql_server_init
>
> #define NULL 0
>
> #include <stdio.h>
>
> int main()
> {
> int res = mysql_library_init(0, NULL, NULL);
> struct MYSQL* cn = mysql_init(NULL);
> printf("here");
> mysql_close(cn);
> return 0;
> }
>
> This program works fine, BUT try commenting out the "printf" call and it
> crashes, too. That said, it is unlikely to be DMD fault here. Are you
> sure those prototypes and/or .lib/.dll files are fine?

I've gone through the entire file and fixed ever wrong definition I found. I added the C declarations as a comment before each type.
The same error exists, and I cannot understand why...

The code is pasted here: http://pastebin.com/KwacZ0MY

Does anyone have a clue where to start looking?

March 05, 2011
On 28.02.2011 18:52, simendsjo wrote:
> I'm trying to wrap the newest mysql c connector, but I get some weird
> bugs. I don't know any assembly, so I don't even know if I've included
> enough info.. I hope this is a small enough test case so someone can
> understand the issue.
> I've used implib on the included dll and rdmd and dmd 2.051 to compile.
>

Asked on SO too: http://stackoverflow.com/questions/5204460/problems-convering-a-c-header-to-d
March 08, 2011
Sorry for not seeing this sooner. I think you might have set the wrong calling convention in the translated header file. See my answer on SO. I hope it works for you now.
March 08, 2011
On 08.03.2011 01:32, Andrej Mitrovic wrote:
> Sorry for not seeing this sooner. I think you might have set the wrong
> calling convention in the translated header file. See my answer on SO.
> I hope it works for you now.

Thanks. Just to get the solution here too:

* Use the vs2005 library (to get COFF?)
* coffimplib
* wrap __stdcall in extern(Windows)

One more thing..
Function pointers in structs.. Should they use extern(Windows) too?
March 09, 2011
On 3/8/2011 12:57 PM, simendsjo wrote:
>
> One more thing..
> Function pointers in structs.. Should they use extern(Windows) too?

Yes.
1 2
Next ›   Last »