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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f0aecf9351d714ac X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!l64g2000hse.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: C Macros and their equivalent in Ada Date: Tue, 9 Sep 2008 13:57:11 -0700 (PDT) Organization: http://groups.google.com Message-ID: <11ad88c5-e158-4718-9fbd-cd3ba5a76627@l64g2000hse.googlegroups.com> References: <90d69a98-ab81-45b2-bd0e-18675b327b66@d77g2000hsb.googlegroups.com> NNTP-Posting-Host: 85.3.74.173 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1220993831 32613 127.0.0.1 (9 Sep 2008 20:57:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 9 Sep 2008 20:57:11 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l64g2000hse.googlegroups.com; posting-host=85.3.74.173; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7693 Date: 2008-09-09T13:57:11-07:00 List-Id: On 9 Wrz, 16:39, Ludovic Brenta wrote: > If you need that feature, you're better off generating an Ada source > file from the "date" utility, e.g. > > echo "package Compilation_Date is" > compilation_date.ads > echo " =A0 Timestamp : constant String :=3D \"$(date --full-ISO)\";" >> > compilation_date.ads > echo "end Compilation_Date;" >> compilation_date.ads This is a simple and valid approach but works only for things that are build-wide. The other extremely useful macros from the C world are __FILE__ and __LINE__. I'm afraid there is no way to simulate them using any external solutions, short of using the real preprocessor (why not?). Yeah - why not use the cpp preprocessor? Let's say that instead of implementing the .adb file we write something that will be used to generate it: $ cat a.adbs with Ada.Text_IO; procedure A is begin Ada.Text_IO.Put_Line (__DATE__ & " " & __TIME__); end A; $ cpp -P a.adbs > a.adb $ gnatmake a gcc -c a.adb gnatbind -x a.ali gnatlink a.ali $ ./a Sep 9 2008 22:53:23 $ Works for me. I can even write a rule in Makefile to make (pun intended) that automated. Not sure if GNAT project files can do it, though. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com Database Access Library for Ada: www.inspirel.com/soci-ada