Commit 2544cbe4 by Arnaud Charlet Committed by Arnaud Charlet

gnat_project_manager.rst, [...]: Update doc.

        * gnat_ugn/gnat_project_manager.rst,
        gnat_ugn/building_executable_programs_with_gnat.rst,
        gnat_ugn/gnat_and_program_execution.rst,
        gnat_ugn/the_gnat_compilation_model.rst,
        gnat_rm/implementation_defined_pragmas.rst,
        gnat_rm/standard_and_implementation_defined_restrictions.rst,
        gnat_ugn.texi, gnat_rm.texi: Update doc.

From-SVN: r230538
parent 767cd81c
2015-11-18 Arnaud Charlet <charlet@adacore.com>
* gnat_ugn/gnat_project_manager.rst,
gnat_ugn/building_executable_programs_with_gnat.rst,
gnat_ugn/gnat_and_program_execution.rst,
gnat_ugn/the_gnat_compilation_model.rst,
gnat_rm/implementation_defined_pragmas.rst,
gnat_rm/standard_and_implementation_defined_restrictions.rst,
gnat_ugn.texi, gnat_rm.texi: Update doc.
2015-11-18 Hristian Kirtchev <kirtchev@adacore.com> 2015-11-18 Hristian Kirtchev <kirtchev@adacore.com>
* contracts.adb (Add_Contract_Item): Chain pragmas Attach_Handler * contracts.adb (Add_Contract_Item): Chain pragmas Attach_Handler
......
...@@ -772,7 +772,7 @@ Pure_Barriers ...@@ -772,7 +772,7 @@ Pure_Barriers
[GNAT] This restriction ensures at compile time that protected entry [GNAT] This restriction ensures at compile time that protected entry
barriers are restricted to: barriers are restricted to:
* simple boolean variables defined in the private part of the * simple variables defined in the private part of the
protected type/object, protected type/object,
* constant declarations, * constant declarations,
* named numbers, * named numbers,
......
...@@ -1306,6 +1306,17 @@ Alphabetical List of All Switches ...@@ -1306,6 +1306,17 @@ Alphabetical List of All Switches
:ref:`Optimization_and_Strict_Aliasing` for details. :ref:`Optimization_and_Strict_Aliasing` for details.
.. index:: -fno-strict-overflow (gcc)
:samp:`-fno-strict-overflow`
Causes the compiler to avoid assumptions regarding the rules of signed
integer overflow. These rules specify that signed integer overflow will
result in a Constraint_Error exception at run time and are enforced in
default mode by the compiler, so this switch should not be necessary in
normal operating mode. It might be useful in conjunction with *-gnato0*
for very peculiar cases of low-level programming.
.. index:: -fstack-check (gcc) .. index:: -fstack-check (gcc)
:samp:`-fstack-check` :samp:`-fstack-check`
...@@ -1548,6 +1559,17 @@ Alphabetical List of All Switches ...@@ -1548,6 +1559,17 @@ Alphabetical List of All Switches
`Check_Float_Overflow` in GNAT RM. `Check_Float_Overflow` in GNAT RM.
.. index:: -gnateg (gcc)
:samp:`-gnateg`
:samp:`-gnatceg`
The `-gnatc` switch must always be specified before this switch, e.g.
`-gnatceg`. Generate a C header from the Ada input file. See
:ref:`Generating_C_Headers_for_Ada_Specifications` for more
information.
.. index:: -gnateG (gcc) .. index:: -gnateG (gcc)
:samp:`-gnateG` :samp:`-gnateG`
......
...@@ -2999,9 +2999,9 @@ exception raised because of the intermediate overflow (and we really ...@@ -2999,9 +2999,9 @@ exception raised because of the intermediate overflow (and we really
would prefer this precondition to be considered True at run time). would prefer this precondition to be considered True at run time).
.. _Overflow_Checking_Modes_in_GNAT: .. _Management_of_Overflows_in_GNAT:
Overflow Checking Modes in GNAT Management of Overflows in GNAT
------------------------------- -------------------------------
To deal with the portability issue, and with the problem of To deal with the portability issue, and with the problem of
...@@ -3202,7 +3202,7 @@ The default mode for overflow checks is ...@@ -3202,7 +3202,7 @@ The default mode for overflow checks is
General => Strict General => Strict
which causes all computations both inside and outside assertions to use which causes all computations both inside and outside assertions to use
the base type. In addition overflow checks are suppressed. the base type.
This retains compatibility with previous versions of This retains compatibility with previous versions of
GNAT which suppressed overflow checks by default and always GNAT which suppressed overflow checks by default and always
...@@ -3220,8 +3220,6 @@ is equivalent to ...@@ -3220,8 +3220,6 @@ is equivalent to
which causes overflow checking of all intermediate overflows which causes overflow checking of all intermediate overflows
both inside and outside assertions against the base type. both inside and outside assertions against the base type.
This provides compatibility
with this switch as implemented in previous versions of GNAT.
The pragma `Suppress (Overflow_Check)` disables overflow The pragma `Suppress (Overflow_Check)` disables overflow
checking, but it has no effect on the method used for computing checking, but it has no effect on the method used for computing
......
...@@ -2390,7 +2390,7 @@ building. The syntax looks like ...@@ -2390,7 +2390,7 @@ building. The syntax looks like
for External ("BUILD") use "PRODUCTION"; for External ("BUILD") use "PRODUCTION";
package Builder is package Builder is
for Switches ("Ada") use ("-q"); for Global_Compilation_Switches ("Ada") use ("-g");
end Builder; end Builder;
end Agg; end Agg;
......
...@@ -4439,7 +4439,7 @@ easier to interface with other languages than previous versions of Ada. ...@@ -4439,7 +4439,7 @@ easier to interface with other languages than previous versions of Ada.
.. _Running_the_binding_generator: .. _Running_the_binding_generator:
Running the binding generator Running the Binding Generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The binding generator is part of the *gcc* compiler and can be The binding generator is part of the *gcc* compiler and can be
...@@ -4534,7 +4534,7 @@ and then generate Ada bindings from this file: ...@@ -4534,7 +4534,7 @@ and then generate Ada bindings from this file:
.. _Generating_bindings_for_C++_headers: .. _Generating_bindings_for_C++_headers:
Generating bindings for C++ headers Generating Bindings for C++ Headers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Generating bindings for C++ headers is done using the same options, always Generating bindings for C++ headers is done using the same options, always
...@@ -4662,6 +4662,91 @@ Switches ...@@ -4662,6 +4662,91 @@ Switches
:samp:`-C` :samp:`-C`
Extract comments from headers and generate Ada comments in the Ada spec files. Extract comments from headers and generate Ada comments in the Ada spec files.
.. _Generating_C_Headers_for_Ada_Specifications:
Generating C Headers for Ada Specifications
-------------------------------------------
.. index:: Binding generation (for Ada specs)
.. index:: C headers (binding generation)
GNAT includes a C header generator for Ada specifications which supports
Ada types that have a direct mapping to C types. This includes in particular
support for:
* Scalar types
* Constrained arrays
* Records (untagged)
* Composition of the above types
* Constant declarations
* Object declarations
* Subprogram declarations
Running the C Header Generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The C header generator is part of the GNAT compiler and can be invoked via
the *-gnatceg* combination of switches, which will generate a :file:`.h`
file corresponding to the given input file (Ada spec or body). Note that
only spec files are processed in any case, so giving a spec or a body file
as input is equivalent. For example:
.. code-block:: sh
$ gcc -c -gnatceg pack1.ads
will generate a self-contained file called :file:`pack1.h` including
common definitions from the Ada Standard package, followed by the
definitions included in :file:`pack1.ads`, as well as all the other units
withed by this file.
For instance, given the following Ada files:
.. code-block:: ada
package Pack2 is
type Int is range 1 .. 10;
end Pack2;
.. code-block:: ada
with Pack2;
package Pack1 is
type Rec is record
Field1, Field2 : Pack2.Int;
end record;
Global : Rec := (1, 2);
procedure Proc1 (R : Rec);
procedure Proc2 (R : in out Rec);
end Pack1;
The above `gcc` command will generate the following :file:`pack1.h` file:
.. code-block:: c
/* Standard definitions skipped */
#ifndef PACK2_ADS
#define PACK2_ADS
typedef short_short_integer pack2__TintB;
typedef pack2__TintB pack2__int;
#endif /* PACK2_ADS */
#ifndef PACK1_ADS
#define PACK1_ADS
typedef struct _pack1__rec {
pack2__int field1;
pack2__int field2;
} pack1__rec;
extern pack1__rec pack1__global;
extern void pack1__proc1(const pack1__rec r);
extern void pack1__proc2(pack1__rec *r);
#endif /* PACK1_ADS */
You can then `include` :file:`pack1.h` from a C source file and use the types,
call subprograms, reference objects, and constants.
.. _GNAT_and_Other_Compilation_Models: .. _GNAT_and_Other_Compilation_Models:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment