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,d36fc3985d071e34 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Vinzent 'Gadget' Hoefler Newsgroups: comp.lang.ada Subject: Re: Pointer address Date: Fri, 31 Dec 2004 09:57:28 +0000 Message-ID: <1902346.BAagqHZ0Mk@jellix.jlfencey.com> References: <1224531.Y4V0fVubSt@jellix.jlfencey.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net htK4MKHUNGjbRpvARcQFMAExJdkjeuImH8oZYRzFf+ww7IrfNv X-Phone: +41 62 961 13 52 Xref: g2news1.google.com comp.lang.ada:7339 Date: 2004-12-31T09:57:28+00:00 List-Id: tmoran@acm.org wrote: > translation of the (non-Windows) design. But since cpdata.dwData is a > variable, there could be other code like > cpdata.dwData = 0x0001B011; > cpdata.dwData = 0x0002C022; > etc, in which case he really would need to use pointers. Yes, agreed. (But of all the C-code that used fixed address values I've seen yet, there was not one that used such a variable in that way.) >>Hmm, one problem: if I change the address to 16#0001B001#, I get >> >>"raised PROGRAM_ERROR : temp.adb:13 misaligned address value". > Objects of type "access all Interfaces.C.Unsigned_Long", most likely > have an alignment of 4, I figured that. ;-) > and ARM 13.3(27) says "Program execution is > erroneous if an Address clause is given that conflicts with the > Alignment." 16#1B001# is not a multiple of 4. What surprised me a little bit was that GNAT didn't warn (ok, I have to admit I didn't turn on all the warnings) or even refused to compile at all. >>What was the target architecture/OS of the original C-Code? Using >>fixed addresses looks like it was assuming DOS or some other system >>with fixed memory areas (like some microcontroller stuff). Such code >>simply will not work with Windows. > > That's a bit strong. Ok, maybe. But even if it "works", the reason why it works might be the wrong one... > The address will be interpreted as a location > in the program's virtual address space, which might be, though > probably isn't, what was meant. I'd say it is very improbable that it does. > Porting this C program to another architecture certainly requires more > than a transliteration into Ada. That's what I was trying to say. ;-) Vinzent.