[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] _M2_EXCEPTIONS_RAISE
From: |
Gaius Mulley |
Subject: |
Re: [Gm2] _M2_EXCEPTIONS_RAISE |
Date: |
Tue, 05 Jan 2010 00:28:43 +0000 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Martin Kalbfuß <address@hidden> writes:
> Thanks a lot,
>
> I'm a step further now. But it still doesn't work. The thrown exception
> is not the user defined one. I realized some mistakes in the code.
>
> 1. AllocateSource takes a variadic parameter.
> 2. EXCEPTIONS_ExceptionSource is not a RECORD. It's a pointer to a
> nameless RECORD.
>
> I changed the code a bit:
>
> ##########################
>
> #include <stdlib.h>
>
> extern "C" void EXCEPTIONS_AllocateSource(void **source);
> extern "C" void EXCEPTIONS_RAISE(void *source, unsigned int number,
> const char *message);
>
> void *exSrc = NULL;
>
> extern "C" void gnuexcept2_Action()
> {
> EXCEPTIONS_RAISE(exSrc, 1, "Hallo Welt");
Hi Martin,
try:
EXCEPTIONS_RAISE(exSrc, 1, "Hallo Welt", strlen("Hallo Welt"));
regards,
Gaius
> }
>
> extern "C" void _M2_gnuexcept2_init()
> {
> EXCEPTIONS_AllocateSource(&exSrc);
> }
>
> extern "C" void _M2_gnuexcept2_finish()
> {
>
> }
>
> ###########################
>
> Now I get a memory access violation. ???
>
>
>
> Am Montag, den 04.01.2010, 20:47 +0000 schrieb Gaius Mulley:
>> Martin Kalbfuß <address@hidden> writes:
>>
>>
>> Hi Martin,
>>
>> the procedures in gnuexcept2.cpp should be referenced by the
>> modulename (EXCEPTIONS) without the _M2_. The _M2_ is only used for
>> init/finish functions. So here is the code with modifications:
>>
>> DEFINITION MODULE gnuexcept2 ;
>>
>> PROCEDURE Action ;
>>
>> END gnuexcept2.
>>
>>
>>
>> typedef struct EXCEPTIONS_ExceptionSource
>> EXCEPTIONS_ExceptionSource;
>> extern "C" void EXCEPTIONS_AllocateSource(EXCEPTIONS_ExceptionSource
>> *source);
>> extern "C" void EXCEPTIONS_RAISE(EXCEPTIONS_ExceptionSource
>> *source, unsigned int number, const char *message);
>>
>> EXCEPTIONS_ExceptionSource *exSrc;
>>
>> extern "C" void gnuexcept2_Action (void)
>> {
>> EXCEPTIONS_RAISE(exSrc, 1, "Hallo Welt");
>> }
>>
>> extern "C" void _M2_gnuexcept2_init()
>> {
>> EXCEPTIONS_AllocateSource(exSrc);
>> }
>>
>> extern "C" void _M2_gnuexcept2_finish()
>> {
>> }
>>
>>
>>
>> MODULE test;
>>
>> IMPORT gnuexcept2;
>>
>> BEGIN
>> gnuexcept2.Action();
>> END test.
>>
>>
>>
>> all: force
>> g++ -c gnuexcept2.cpp
>> gm2 -fiso -c test.mod
>> gm2 -fiso test.mod
>>
>> clean: force
>> $(RM) *.o a.out *~
>>
>> force:
>>
>>
>>
>> regards,
>> Gaius