← 返回命令列表

Linux command

gnat 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Compile an Ada program

gcc -c [program.adb]

Build an Ada executable

gnatmake [program.adb]

Bind an Ada program

gnatbind [program]

Link an Ada program

gnatlink [program]

Compile with all warnings

gnatmake -gnatwa [program.adb]

Clean built files

gnatclean [program]

Check syntax only

gcc -c -gnats [program.adb]

Generate cross-reference

gnatxref [program.adb]

说明

GNAT (GNU Ada Translator) is the Ada compiler in the GCC collection. It compiles Ada 83, Ada 95, Ada 2005, and Ada 2012 programs. Ada source files use .ads (specification) and .adb (body) extensions. The GNAT build process has three phases: compilation (gcc -c), binding (gnatbind), and linking (gnatlink). The gnatmake tool automates all three, determining dependencies and recompiling only what is necessary.

参数

-c
Compile only, do not link (required for gcc with Ada).
-gnatwa
Enable all warnings.
-gnato
Enable numeric overflow checking.
-gnats
Syntax check only.
-gnatc
Semantic check only.
-gnatf
Full errors (verbose error messages).
-O_N_
Optimization level (0-3).
-g
Include debugging information.

FAQ

What is the gnat command used for?

GNAT (GNU Ada Translator) is the Ada compiler in the GCC collection. It compiles Ada 83, Ada 95, Ada 2005, and Ada 2012 programs. Ada source files use .ads (specification) and .adb (body) extensions. The GNAT build process has three phases: compilation (gcc -c), binding (gnatbind), and linking (gnatlink). The gnatmake tool automates all three, determining dependencies and recompiling only what is necessary.

How do I run a basic gnat example?

Run `gcc -c [program.adb]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -c do in gnat?

Compile only, do not link (required for gcc with Ada).