From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2e1cd42feeec2424,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail From: "Garry" Newsgroups: comp.lang.ada Subject: Interfacing to C Date: 8 Feb 2005 10:07:58 -0800 Organization: http://groups.google.com Message-ID: <1107886078.800063.121210@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: 68.15.177.42 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1107886083 5189 127.0.0.1 (8 Feb 2005 18:08:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 8 Feb 2005 18:08:03 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: f14g2000cwb.googlegroups.com; posting-host=68.15.177.42; posting-account=EMtA8g0AAAA-UNlGV18CQWXjhlUjxiBB Xref: g2news1.google.com comp.lang.ada:8192 Date: 2005-02-08T10:07:58-08:00 List-Id: I'm just starting in ADA. Can anyone explain why I have to define a dummy procedure in my hsdbg package to get my code to work? Error without dummy procedure: hsdbg.ads:4:09: package "HSDBG" does not allow a body hsdbg.ads:4:09: remove incorrect body in file "hsdbg.adb" gnatmake: "hsdbg.ads" compilation error error: "hsdbg.adb" must be recompiled ("hsdbg.ads" has been modified) gnatlink: Failed to open binder output Code follows: /* Start of marktime.c */ #include void marktime(char str[255]) { printf("marktime: str='%s'\n",str); } /* End of marktime.c */ -- Start of hsdbg.ads -- with Interfaces.C; with Interfaces.C.Strings; package HSDBG is -- Dummy procedure? type DUMB is digits 5 range 0.0 .. 1.0E10; procedure DUMMY (B : DUMB); -- End Dummy procedure procedure marktime(Variable : Interfaces.C.Strings.chars_ptr); pragma Import(C, marktime, "marktime"); end HSDBG; -- End of hsdbg.ads -- Start of hsdbg.adb -- with Ada.Text_IO; use Ada.Text_IO; with Interfaces.C.Strings; use Interfaces.C.Strings; -- -- Define package body -- package body HSDBG is -- -- -- dummy procedure? procedure DUMMY(B : DUMB) is begin put("In Dummy"); end DUMMY; -- end dummy procedure procedure marktime(Variable : String) is procedure marktime(Variable : chars_ptr); pragma Import(C, marktime, "marktime"); Variable_In_C_Format : chars_ptr := New_String(Variable); begin marktime(Variable_In_C_Format); Free(Variable_In_C_Format); end marktime; end HSDBG; -- End of hsdbg.adb -- Start of tst.adb with Ada.Text_IO; use Ada.Text_IO; with Interfaces.C.Strings; use Interfaces.C.Strings; with hsdbg; use hsdbg; procedure tst is C_Format : chars_ptr := New_String("This is a string in ADA that is written by the marktime C procedure"); begin Put_Line ("test started"); marktime(C_Format); end tst; -- End of tst.adb