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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:e48b:: with SMTP id o133-v6mr6024205ith.0.1539950903284; Fri, 19 Oct 2018 05:08:23 -0700 (PDT) X-Received: by 2002:aca:7552:: with SMTP id q79-v6mr600939oic.1.1539950903074; Fri, 19 Oct 2018 05:08:23 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.215.MISMATCH!z5-v6no51662ite.0!news-out.google.com!n199-v6ni82itn.0!nntp.google.com!z5-v6no51657ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 19 Oct 2018 05:08:22 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2607:f2c0:95d0:2100:44a4:f239:cac4:1a94; posting-account=cUi90woAAADTaOISowbbHM8GUD0-opJO NNTP-Posting-Host: 2607:f2c0:95d0:2100:44a4:f239:cac4:1a94 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8ca9b14d-e62d-4645-8b20-50bdb8ad7935@googlegroups.com> Subject: Very Excited About GnuCOBOL and Ada :) From: patrick@spellingbeewinnars.org Injection-Date: Fri, 19 Oct 2018 12:08:23 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:54651 Date: 2018-10-19T05:08:22-07:00 List-Id: Hi Everyone I just wanted to share something I am excited about. I have been mixing Gnu= COBOL and Ada for some time but the process was not a lot of fun. I have had more luck this week. Here is what I did. I took Gnat.ByteSwappin= g and renamed it so that I would not accidentally end up using the one inst= alled in my /usr/xxx directory. I was able to use it without really writing any Ada code. I just had to mod= ify the spec file a little bit. Here is the code: Commands to build-> gcc -c gnat_byteswap.adb gnatbind -n gnat_byteswap.ali gcc -c b~gnat_byteswap.adb cobc -x experiment.cob gnat_byteswap.o b~gnat_byteswap.o -lgnat Altered Part Of Spec file: procedure Swap2 (Location : System.Address); pragma export(C, Swap2, "swap2") ; procedure Swap4 (Location : System.Address); pragma export(C, Swap4, "swap4") ; procedure Swap8 (Location : System.Address); pragma export(C, Swap8, "swap8") ; The Body is unchanged. Here is the GnuCOBOL program: >>> source format is free identification division. program-id. "experiment" . data division. working-storage section. 01 2bytes pic x(2) value is "AB" . 01 4bytes pic x(4) value is "ABCD" . 01 8bytes pic x(8) value is "ABCDEFGH" . procedure division . call "adainit" end-call call "swap2" using by reference 2bytes end-call call "swap4" using by reference 4bytes end-call call "swap8" using by reference 8bytes end-call display 2bytes display 4bytes display 8bytes goback . end program "experiment" . GnuCOBOL support many code styles, this is just mine and not representative= . Notice that I used pragma export(C... ) and not COBOL. I am not confident i= n Ada's current support of COBOL. I am going to investigate this further an= d I hope to add missing functionality such as support for pointers and func= tions found in GnuCOBOL. It's really exciting to simply take Ada library code, alter it just a bit w= ith pragma export and then be able to use it in GnuCOBOL. I don't know Fort= ran as well but I am going to also try to do the same thing with gfortran. = I am going to share this with the GnuCOBOL community soon and then eventual= ly the gfortran one too. The same process could also bring Ada libraries to= C and C++ users with minimal fuss. Code changes could just come in the for= m of patches.