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 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.43.52.200 with SMTP id vn8mr15414877icb.21.1381866859035; Tue, 15 Oct 2013 12:54:19 -0700 (PDT) X-Received: by 10.49.94.41 with SMTP id cz9mr77859qeb.26.1381866858985; Tue, 15 Oct 2013 12:54:18 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!o2no6875435qas.0!news-out.google.com!9ni44722qaf.0!nntp.google.com!i2no14422959qav.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 15 Oct 2013 12:54:18 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=129.59.203.120; posting-account=7Oy7OQoAAABhVYFOo553Cn1-AaU-bSfl NNTP-Posting-Host: 129.59.203.120 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Passing a String to a C/C++ Subprogram (Special Case) From: Eryndlia Mavourneen Injection-Date: Tue, 15 Oct 2013 19:54:19 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:17425 Date: 2013-10-15T12:54:18-07:00 List-Id: I have a couple of strings that are bounded; that is, they are essentially = fixed-length strings, and I need to pass them as "in" parameters to a subpr= ogram that may or may not be written in C/C++. I don't really want to hass= le with the Interfaces packages for this, since the subprogram language is = indefinite, and the strings are part of a package that many others likely w= ill want to use, and the strings most likely will be used as standard Ada f= ixed-length strings. Q: Is there any reason that I cannot just declare each of them in this way,= assuming the subprogram is written in C/C++: . . . A_String : String (1 .. 30); pragma Convention (C, A_String); . . . procedure C_Prog (C_String : in String); pragma Import (Entity =3D> C_Prog, ...); begin C_Prog (C_String =3D> A_String); . . . and have it work properly? This method, of course, leaves it up to the client developer to insert any = necessary nul characters to terminate the string, if is is smaller than the= declared bound. -- Eryndlia Mavourneen (KK1T)