comp.lang.ada
 help / color / mirror / Atom feed
From: David Thompson <dave.thompson2@verizon.net>
Subject: Re: pragma import (C, , ); -- import a constant value from C library
Date: Sun, 04 Nov 2012 22:41:46 -0500
Date: 2012-11-04T22:41:46-05:00	[thread overview]
Message-ID: <bvce98p1nff9uc6p7htblrt26jn0qdol2n@4ax.com> (raw)
In-Reply-To: 1c65196f-68e4-4b50-8ad0-e9555d3f1b50@googlegroups.com

On Sat, 27 Oct 2012 00:15:06 -0700 (PDT), Maciej Sobczak
<see.my.homepage@gmail.com> wrote:

> W dniu sobota, 27 pa?dziernika 2012 01:06:14 UTC+2 u?ytkownik Simon Wright napisa?:
> 
> >    const double m_euler_for_gnat = M_EULER;
> 
> You might want to declare this variable with external linkage (the logic is: if you want to 
import something from Ada, then you have to export it from C), so:
> 
>     extern "C" const double m_euler_for_gnat = M_EULER;

No, that's a syntax error in C. (C has static, and extern, but not
extern "language"; that's a creation of C++.)

In C++ officially you need extern "C" to specify language linkage
(although in many implementations this is actually needed only on
routines not variables).

A global definition in C (at file scope, with "extern" or with no
storage-class specifier) has external linkage, which means the name is
visible to separately compiled modules (including Ada).




  reply	other threads:[~2012-11-05  3:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26 22:45 pragma import (C, , ); -- import a constant value from C library Enzo Guerra
2012-10-26 23:06 ` Simon Wright
2012-10-27  7:15   ` Maciej Sobczak
2012-11-05  3:41     ` David Thompson [this message]
2012-10-27  7:40 ` Dmitry A. Kazakov
2012-10-27  8:15   ` Simon Wright
2012-10-27  8:19   ` Simon Wright
2012-10-27  8:47     ` Dmitry A. Kazakov
replies disabled

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