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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!att!cbnewsl!arny From: arny@cbnewsl.ATT.COM (arny.b.engelson) Newsgroups: comp.lang.ada Subject: Re: Questions on Ada... Message-ID: <979@cbnewsl.ATT.COM> Date: 3 Jul 89 13:51:02 GMT References: <3034@wpi.wpi.edu> Reply-To: arny@cbnewsl.ATT.COM (arny.b.engelson) Distribution: usa Organization: AT&T Bell Laboratories List-Id: In article <3034@wpi.wpi.edu> tfrancis@wpi.wpi.edu (Krishan M Nainani) writes: > >(1) Is there any way to mimic the C pre-processor commands in Ada. > For example, is it possible to mimic: > #ifdef TEMP > ... > #endif Well, sort of. It is really outside of the language, but you can use the same C pre-processor commands, and simply run the code through the C pre- processor before running it through the Ada compiler. I have actually seen people do this, and it has worked quite well. It may not be so hot from a Configuration Management point of view, and will get some Ada purists up in arms, but it works. On some compilers you may be able to achieve this using Pragmas, keeping the code true Ada, but unusable on other systems. >(2) Is it possible to copy sections of memory regardless of its > contents from one type to another. For example, in C: > > atype : *ptr1; btype : *ptr2; /* atype and btype are different */ > for (i=0;i<123;i++) *ptr1++ = *ptr2++; There is more than one way to do this. One alternative is to use overlays. Simply declare an integer array of the proper length, use an address clause to overlay it at the location occupied by the structure you are copying from, and copy it to an integer array overlayed at the destination address. Another alternative is to use unchecked conversion from one type to another. Again, the Ada purists will be up in arms (overlays are officially erroneous), but the concept is very useful in some situations. BTW, erroneous doesn't mean it won't work, but it does mean you had better be sure you know what you are doing. >Thanx in advance. You're welcome. >Krishan Nainani. reply-to: tfrancis@wpi.wpi.edu - Arny Engelson wayback!arny