comp.lang.ada
 help / color / mirror / Atom feed
From: Thierry Lelegard <thierry.lelegard@canal-plus.fr>
Subject: Re: How pass a "null" as a parameter of anonymous access type
Date: Tue, 27 Mar 2001 18:53:32 +0200
Date: 2001-03-27T18:53:32+02:00	[thread overview]
Message-ID: <3AC0C58C.F5E2C4F6@canal-plus.fr> (raw)
In-Reply-To: zBMv6.627492$U46.19173114@news1.sttls1.wa.home.com

[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]

> Freddy <Alfred.Hilscher.X@t-online.de> wrote in message
> news:3ABE6443.4119AB52@t-online.de...
> > Thanks. I've tried it, but at runtime I always get a constraint_error
> > (GNAT seems to check the passing of "null" values).
> 
> Yes -- as any correct Ada compiler must do!
> 
> The value "null" just does not exist for the type of the parameter.
> 
> Now, you might be able use "pragma Suppress (Access_Check)" to defeat this.

I don't agree. I don't use the value "null". I use a variable which
pretends to be at address zero.

The following example works with GNAT 3.15w (20010305) on Sun Solaris.
But, again, this is a hack, unsupported non-standard Ada.

$ cat tnull.adb
with System;

procedure Tnull is

    Null_Access : aliased Integer;
    for Null_Access'Address use System.Null_Address;

    procedure Tnull_C (X : access Integer);
    pragma Import (C, Tnull_C, "tnull_c");

begin
    Tnull_C (Null_Access'Access);
end Tnull;
$ 
$ cat tnull_c.c 
#include <stdio.h>

void tnull_c (int *x)
{
    printf ("x add = %08X\n", x);
}
$
$ gcc -c tnull_c.c
$ gnatmake tnull -largs tnull_c.o
gcc -c tnull.adb
gnatbind -x tnull.ali
gnatlink tnull_c.o tnull.ali
$ tnull
x add = 00000000
$ 

-Thierry
____________________________________________________________________________

Thierry Lelegard, "The Jazzing Troll", Email: thierry.lelegard@canal-plus.fr
CANAL+ Technologies, 34 place Raoul Dautry, 75516 Paris Cedex 15, France
Tel: +33 1 71 71 54 30   Fax: +33 1 71 71 52 08   Mobile: +33 6 03 00 65 75
____________________________________________________________________________

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Carte pour Thierry Lelegard --]
[-- Type: text/x-vcard; charset=us-ascii; name="thierry.lelegard.vcf", Size: 333 bytes --]

begin:vcard 
n:Lel�gard;Thierry
tel;cell:+33 6 03 00 65 75
tel;fax:+33 1 71 71 52 08
tel;work:+33 1 71 71 54 30
x-mozilla-html:FALSE
url:www.canalplus-technologies.com
org:Canal+ Technologies
adr:;;34, Place Raoul Dautry;Paris;;75516;France
version:2.1
email;internet:thierry.lelegard@canal-plus.fr
fn:Thierry Lel�gard
end:vcard

  parent reply	other threads:[~2001-03-27 16:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-22 20:04 How pass a "null" as a parameter of anonymous access type Freddy
2001-03-22 21:02 ` tmoran
2001-03-25 21:32   ` Freddy
2001-03-26 14:31     ` How pass a Ted Dennison
2001-03-23  9:05 ` How pass a "null" as a parameter of anonymous access type Thierry Lelegard
2001-03-25 21:33   ` Freddy
2001-03-26 19:17     ` Mark Lundquist
2001-03-27 16:13       ` Alfred Hilscher
2001-03-27 16:53       ` Thierry Lelegard [this message]
2001-03-26 13:44 ` Marc A. Criley
2001-03-26 19:35   ` Mark Lundquist
2001-03-27 12:59     ` Marc A. Criley
2001-03-27 16:12       ` Alfred Hilscher
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox