gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: [Gm2] Calling Modula-2 from C


From: Gaius Mulley
Subject: re: [Gm2] Calling Modula-2 from C
Date: Fri, 29 May 2009 19:47:32 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Hi,

at present it is probably easier to make Modula-2 call C.  Thus
allowing Modula-2 to create the main function.  So you might write the
C module as:

/*
 *  file:  qqq.c
 */
#include <stdio.h>

void helloworld_hello();

int mymain (void) {
    helloworld_hello();
    return 0
}

----- >o ----- >o ----- >o ----- >o ----- >o 

DEFINITION MODULE FOR "C" qqq ;

EXPORT UNQUALIFIED mymain ;

PROCEDURE mymain () : INTEGER ;

END qqq.

----- >o ----- >o ----- >o ----- >o ----- >o 

MODULE test ;

(*
 *  test.mod
 *)

FROM qqq IMPORT mymain ;

VAR
   i: INTEGER ;
BEGIN
   i := mymain()
END test.

----- >o ----- >o ----- >o ----- >o ----- >o 


gm2 -g -c test.mod
gcc -g -c qqq.c
gm2 -g test.mod qqq.o

which should result in an 'a.out'

regards,
Gaius




reply via email to

[Prev in Thread] Current Thread [Next in Thread]