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,ad4585f2971e47c5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!feeder.news-service.com!194.255.237.131.MISMATCH!newsfeed101.telia.com!starscream.dk.telia.net!news.tele.dk!feed118.news.tele.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail From: "Luis P. Mendes" Subject: Re: Need some light on using Ada or not Newsgroups: comp.lang.ada References: <4d5ef836$0$23753$14726298@news.sunsite.dk> <7ibvl6tn4os3njo3p4kek9kop44nke3n7t@4ax.com> User-Agent: Pan/0.133 (House of Butterflies) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 20 Feb 2011 00:20:56 GMT Message-ID: <4d605e67$0$23753$14726298@news.sunsite.dk> Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 89.180.58.96 X-Trace: news.sunsite.dk DXC=iN3Om0Z7C8>OVgHIS4l:13YSB=nbEKnk;=Wf0P_7c\Z6EHH=C_KSIR7lc:4cA5P5i5Y61G6h^GXk1fQLBf=?lI08Z=3=1R0YQk= X-Complaints-To: staff@sunsite.dk Xref: g2news2.google.com comp.lang.ada:18436 Date: 2011-02-20T00:20:56+00:00 List-Id: Sat, 19 Feb 2011 13:07:58 +0000, Brian Drummond escreveu: > Ada can easily bind to C libraries, it's standard and well documented. > > However there already exist bindings to some graphics libraries and data > visualisation tools - look at GTKAda and QTAda for GUI and some graphics > bindings, and PLPlot for data visualisation. One of these may work for > you. > > C++ bindings are also possible, but with some work and (currently) some > limitations. > A GCC recent enough to support "-f-dump-ada-spec" will auto-generate an > Ada spec from C++ sources, which will save a lot of the work. (Adacore > "libre" 2010 has it; the FSF GCC 4.5.0 has not. Anyone know if it made > it into 4.5.1 or 4.6.0?) > > I would currently treat that binding as a starting point rather than a > complete solution. For example, it (libre "GPL2010" from Adacore) has > problems with templates. (Especially when your well-proven C++ template > library still has bugs that Ada generics would have caught first time > through the compiler!) Would you mind giving me an example? Please consider the following C++ code: ===== header file $ cat aleatorio.h #ifndef GUARD_aleatorio_h #define GUARD_aleatorio_h #include #include #include void iniciarSemente(); double gerarAleatorio(int a, int b); int gerarAleatorioInteiro(int a, int b); int arredondar(double res); #endif ===== source file $ cat aleatorio.cpp #include #include #include #include "aleatorio.h" #include using std::srand; using std::rand; void iniciarSemente() { srand(time(NULL)); //srand(10); //gerar sempre a mesma semente para comparacoes } double gerarAleatorio(int a, int b) { return (b-a) * ( (double) rand()/RAND_MAX) + a; } int arredondar(double res) { return (res > 0.0) ? floor(res + 0.5) : ceil(res - 0.5); } int gerarAleatorioInteiro(int a, int b) { // verificar colocação do (int), parêntesis float res; res = gerarAleatorio(a, b); return arredondar(res); } ===== >From Ada, how can I use these h and cpp files to call, for example, gerarAleatorioInteiro(0,10)? Luis