1. C_func problems...
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 25, 2004
- 594 views
Can anybody tell me why the following code has a machine-level exception error when run? The relevant msdn entry is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createmutex.asp Very frustrating...
constant NULL = -1 include dll.e include machine.e constant kernel32 = open_dll("kernel32") --HANDLE CreateMutex( -- LPSECURITY_ATTRIBUTES lpMutexAttributes, -- BOOL bInitialOwner, -- LPCTSTR lpName --); constant xCreateMutex = define_c_func(kernel32, "CreateMutexA", {C_POINTER, C_CHAR, C_POINTER}, C_INT ) function createMutex(sequence name) atom ret, str str = allocate_string(name) ret = c_func(xCreateMutex, {NULL, 0, str}) free(str) return ret end function ? createMutex("testing")
-- MrTrick
2. Re: C_func problems...
- Posted by Greg Haberek <ghaberek at gmail.com> Nov 25, 2004
- 596 views
NULL should be 0, not -1 -1 is sent to a C function as #FFFFFFFF and it thinks that's a memory address (pointer) of a the structure LPSECURITY_ATTRIBUTES. 0, on the other hand, is an empty memory address. On Thu, 25 Nov 2004 17:04:10 +1100, Patrick Barnes <mrtrick at gmail.com> wrote: > > Can anybody tell me why the following code has a machine-level > exception error when run? > > The relevant msdn entry is here: > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createmutex.asp > > Very frustrating... > > }}} <eucode> > constant NULL = -1 > include dll.e > include machine.e > constant kernel32 = open_dll("kernel32") > --HANDLE CreateMutex( > -- LPSECURITY_ATTRIBUTES lpMutexAttributes, > -- BOOL bInitialOwner, > -- LPCTSTR lpName > --); > constant xCreateMutex = define_c_func(kernel32, "CreateMutexA", > {C_POINTER, C_CHAR, C_POINTER}, C_INT ) > > function createMutex(sequence name) > atom ret, str > str = allocate_string(name) > ret = c_func(xCreateMutex, {NULL, 0, str}) > free(str) > return ret > end function > > ? createMutex("testing") > </eucode> {{{ > > -- > MrTrick > >
3. Re: C_func problems...
- Posted by Bernie Ryan <xotron at bluefrog.com> Nov 25, 2004
- 542 views
BOOL bInitialOwner BOOL should be C_INT Bernie My files in archive: w32engin.ew mixedlib.e eu_engin.e win32eru.ew Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
4. Re: C_func problems...
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 25, 2004
- 560 views
- Last edited Nov 26, 2004
On Thu, 25 Nov 2004 09:22:23 -0800, Bernie Ryan <guest at rapideuphoria.com> wrote: > BOOL bInitialOwner > > BOOL should be C_INT Why C_INT? What's wrong with C_CHAR? -- MrTrick ------------------------------------------------------------------------------------- magnae clunes mihi placent, nec possum de hac re mentiri.
5. Re: C_func problems...
- Posted by Bernie Ryan <xotron at bluefrog.com> Nov 25, 2004
- 611 views
- Last edited Nov 26, 2004
Patrick Barnes wrote: > > On Thu, 25 Nov 2004 09:22:23 -0800, Bernie Ryan <guest at rapideuphoria.com> > wrote: > > BOOL bInitialOwner > > > > BOOL should be C_INT > > Why C_INT? What's wrong with C_CHAR? > > -- > MrTrick > > ------------------------------------------------------------------------------------- > magnae clunes mihi placent, nec possum de hac re mentiri. > > Because if you ever use it in a structure as C_CHAR windows will be passed the wrong size structure, so I suggest that you always use C_INT, it is not absolutely necessasry in this case. Bernie My files in archive: w32engin.ew mixedlib.e eu_engin.e win32eru.ew Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
6. Re: C_func problems...
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 25, 2004
- 582 views
- Last edited Nov 26, 2004
On Thu, 25 Nov 2004 14:38:11 -0800, Bernie Ryan <guest at rapideuphoria.com> wrote: > Patrick Barnes wrote: > > > > On Thu, 25 Nov 2004 09:22:23 -0800, Bernie Ryan <guest at rapideuphoria.com> > > wrote: > > > BOOL bInitialOwner > > > > > > BOOL should be C_INT > > > > Why C_INT? What's wrong with C_CHAR? > > Because if you ever use it in a structure as C_CHAR windows > will be passed the wrong size structure, so I suggest that > you always use C_INT, it is not absolutely necessasry in this case. > Okay, thanks. It did turn out that the NULL being defined improperly was the issue. -- MrTrick