RosettaCodeData/Task/Call-a-foreign-language-function/Modula-3/call-a-foreign-language-function.mod3

18 lines
409 B
Text
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
UNSAFE MODULE Foreign EXPORTS Main;
IMPORT IO, Ctypes, Cstring, M3toC;
VAR string1, string2: Ctypes.const_char_star;
BEGIN
string1 := M3toC.CopyTtoS("Foobar");
string2 := M3toC.CopyTtoS("Foobar2");
IF Cstring.strcmp(string1, string2) = 0 THEN
IO.Put("string1 = string2\n");
ELSE
IO.Put("string1 # string2\n");
END;
M3toC.FreeCopiedS(string1);
M3toC.FreeCopiedS(string2);
END Foreign.