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,FREEMAIL_FROM, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c1bdceb867926fdb X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!c10g2000yqi.googlegroups.com!not-for-mail From: Ada novice Newsgroups: comp.lang.ada Subject: Re: Interfacing Ada with C Date: Sun, 25 Jul 2010 07:12:09 -0700 (PDT) Organization: http://groups.google.com Message-ID: <91c174e6-c359-4bf5-b284-d93a725ad09d@c10g2000yqi.googlegroups.com> References: <0ee9eec7-6024-4fb8-8df0-f65c146e4b84@i28g2000yqa.googlegroups.com> <143ef70b-7e74-426b-a621-a5fd157849be@x21g2000yqa.googlegroups.com> <18zszx6sjlloa$.k5nohxp9k27i$.dlg@40tude.net> NNTP-Posting-Host: 193.11.22.91 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1280067130 29668 127.0.0.1 (25 Jul 2010 14:12:10 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 25 Jul 2010 14:12:10 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: c10g2000yqi.googlegroups.com; posting-host=193.11.22.91; posting-account=Rr9I-QoAAACS-nOzpA-mGxtAlZ46Nb6I User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12543 Date: 2010-07-25T07:12:09-07:00 List-Id: Thanks a lot. On compilation I get: 1. package body IMSL is 2. procedure Free ( 3. Ptr : System.Address); | >>> "System" is not visible >>> non-visible declaration at system.ads:40 4. pragma Import (C, Free, "free"); 5. 6. function F_Eig_Gen ( 7. Matrix : Float_Matrix) 8. return Complex_Array is 9. begin 10. if Matrix'Length (1) /= Matrix'Length (2) then 11. raise Constraint_Error; 12. end if; 13. declare -- No idea, how they report convergence/accuracy errors 14. function Internal ( | >>> missing body for "Internal" 15. N : Int; 16. A : Address; | >>> "Address" is not visible (more references follow) >>> non-visible declaration at system.ads:67 17. Terminator : Address := Null_Address) | >>> "Null_Address" is not visible >>> non-visible declaration at system.ads:69 18. return Address; 19. pragma Import (C, Internal, "imsl_f_eig_gen"); 20. Ptr : Address := Internal (Matrix'Length 21. (1), Matrix (Matrix'First (1), Matrix'First (2))'Address); 22. Data : Complex_Array (1 .. Matrix'Length (1)); 23. for Data'Address use Ptr; 24. pragma Import (Ada, Data); 25. Result : Complex_Array := Data; -- Copy, we don't own that memory 26. begin 27. Free (Ptr); 28. return Result; 29. end; 30. end F_Eig_Gen; 31. end IMSL; Compiling: c:/docume~1/testing/imsl.ads (source file time stamp: 2010-07-25 14:00:52) 1. with Interfaces.C; 2. use Interfaces.C; 3. package IMSL is 4. type Float_Matrix is -- Row-wise, packed/aligned 5. array (Positive range <>, Positive range <>) of C_Float; 6. pragma Convention (C, Float_Matrix); 7. type F_Complex is 8. record 9. Re : C_Float; 10. Im : C_Float; 11. end record; 12. pragma Convention (C, F_Complex); 13. type Complex_Array is array (Positive range <>) of F_Complex; 14. pragma Convention (C, Complex_Array); 15. 16. function F_Eig_Gen ( 17. Matrix : Float_Matrix) 18. return Complex_Array; 19. end IMSL; 31 lines: 7 errors And what do I need on the C side? Thanks YC