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 2002:a24:640e:: with SMTP id t14-v6mr355654itc.0.1530005205544; Tue, 26 Jun 2018 02:26:45 -0700 (PDT) X-Received: by 2002:aca:5f05:: with SMTP id t5-v6mr99150oib.2.1530005205342; Tue, 26 Jun 2018 02:26:45 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!d7-v6no575520itj.0!news-out.google.com!p13-v6ni618itf.0!nntp.google.com!d7-v6no575516itj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 26 Jun 2018 02:26:45 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=101.164.108.182; posting-account=wavAeAoAAAAZF_sXSZepBukuPCBO0Zqt NNTP-Posting-Host: 101.164.108.182 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8808f0da-a96b-456b-b827-f2aae18fc8f4@googlegroups.com> Subject: Re: Problem Building Ada Interface To ImageMagick 7 From: alby.gamper@gmail.com Injection-Date: Tue, 26 Jun 2018 09:26:45 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:53319 Date: 2018-06-26T02:26:45-07:00 List-Id: On Tuesday, June 26, 2018 at 6:28:57 PM UTC+10, Roger wrote: > OSX 10.13.5 > GNAT community 2018 > XCode 9.4.1 > > ImageMagic Libraries: > libMagick++-7.Q16HDRI > libMagickCore-7.Q16HDRI > > I have been developing some Ada Interfaces To ImageMagick 7 but have come to a problem that I need help with. > I built the ImageMagick libraries with: > CC=clang CXX="clang++ -std=c++11 -stdlib=libc++ -g -O0" CFLAGS="-g -O0" CXXFLAGS="-g -O0" ./configure --prefix=/opt --with-quantum-depth=16 --disable-dependency-tracking --without-perl > I enabled debugging (-g) to allow me to track through the ImageMagick code , C++ in particular which I find almost impossible to reverse engineer from the source alone. > My C++ capabilities are very limited. > > The following code works OK under XCode but crashes (segmentation fault) under GNAT. > > #include > #include > #include "/opt/include/ImageMagick-7/Magick++.h" > #include "Image.h" > > using namespace Magick; > > int main() > { > Image anImage; > > ssize_t max_length = 0; > ssize_t foo_len; > ssize_t copied_str_len = 0; > ssize_t buff_len = 4096; > size_t rows = 0; > std::string foo("12345678901234567890\n12345678901234567890"); > std::string bf = ""; > char bar[buff_len]; > > max_length=sizeof(foo) - 1; > foo_len=foo.length(); > printf ("foo length %zd bytes.\n", foo_len); > > printf ( "Maximum length: %zd\n", max_length); > printf ("Rows: %zd\n", rows); > try {bf = anImage.baseFilename();} > catch (Error& my_error) {printf ("%s", my_error.what());} > catch (...) {printf ("Unhandled error\n");} > printf ("Rows: %zd\n", rows); > printf ("baseFilename: %s\n", anImage.baseFilename().c_str()); > > printf ("Copied string length: %zd\n", copied_str_len); > printf ("bar: \n%s\n", bar); > } > > Under GNAT GPS it produces: > foo length 41 bytes. > Maximum length: 7 > Rows: 0 > [2018-06-26 18:02:10] process terminated successfully, elapsed time: 00.73s > So it appears to terminate after the first printf ("Rows: %zd\n", rows); > That is, it terminates during the call to anImage.baseFilename(); > > When I run the executable from the terminal: > foo length 41 bytes. > Maximum length: 7 > Rows: 0 > Segmentation fault: 11 > > Running the same code under XCode produces. > > foo length 41 bytes. > Maximum length: 23 > Rows: 0 > Rows: 0 > baseFilename: > Copied string length: 0 > bar: > > Program ended with exit code: 0 > The code above is a cut down version of my test code. > The complete version works under XCode. > > The problem seems to concern C++ string processing. > A problem that one of my build attempts reported appeared to concern the string Swap function being unable to handle null parameters. > Unfortunately, I can't recall how I got that information. > > I have tried numerous methods to solve this problem but am unable to. It seems that GNAT is using a different C++ compiler to XCode but I've had no success trying to remedy that idea. > > Positive advice on how to proceed will be greatly appreciated. Hi Roger GNAT uses the GCC "C/C++" compiler or more specifically GNAT is actually part of GCC (GNU compiler collection"). GNAT community edition 2018 uses gcc version 7.3 As far as I am aware XCode uses the LLVM/CLANG C/C++ compiler Alex