0

我将从事一个使用 Ada 语言的软件开发项目。客户正在使用 Rational Apex Ada 编译器,而我将使用 GNU 编译器。我的代码应该可以在客户的电脑上正常工作。Ada 语言中所有可能的编译器相关代码是什么?这样我就可以开发一个独立于编译器的代码。我也想在我的电脑上编译和执行客户的代码。

谢谢 Padmapriya

4

4 回答 4

4

GNAT Pro 的下一个版本将提供一个新的“pragma Profile (Rational)”来帮助从 Apex 移植到 GNAT。有关说明,请参见http://docs.adacore.com/gnat-unw-docs/html/gnat_rm_2.html#SEC110

于 2013-02-22T13:59:54.647 回答
1

In my experience, your main difficulty in going between Gnat and another vendor's compiler is going to be dealing with Gnat's oddball file naming requirements. I believe that Rational, like most compilers, will happily use whatever filename you give it, and just keeps track of the mapping with internal files. Gnat is not so forgiving (but doesn't require the internal mapping files).

So if you folks are writing everything from scratch, my reccomendation would be to standardize on Gnat's preferred file naming. This means one source file per Ada program unit, with the file name matching the program unit name, but all lower-case, and dots replaced by hyphens. Package specifications use the .ads extension, and program unit bodies use .adb.

Otherwise, there isn't much reason why the code can't be completely portable. I worked on one job that had a high-fidelity flight simulator built with a Intermetrics-based front-end for a VxWorks OS target that we were able to rebuild with Gnat at our (Win32) desks for basic desk testing. Even the hard real-time scheduler ported over just fine, as it used all Ada tasking primitives in its implementation. IIRC, the only non-portable calls we had to deal with were a BIOS call to set the TOD clock from its battery backup, and a single VxWorks OS call to set its Real-time Clock frequency. Figuring out how to get everything gnatchopped properly took far more time than stubbing out those two calls.

于 2013-02-21T15:02:40.643 回答
1

“编译器相关代码”在 Ada 中的作用比在许多其他语言(例如 C 或 C++)中要小得多。但是,依赖于编译器的包并不少见,并且也可能存在编译器特定的编译指示和属性。

根据我的经验,Rational Apex 开发人员似乎倾向于过度(恕我直言)使用 Rational 提供的包。

要么必须移植或重新实现此类包,要么重新编码与它们交互的 Ada 以使用纯 Ada 方法,这是高度首选的选项。

于 2013-02-21T14:29:45.963 回答
1

我当前的项目使用了一些特定于编译器的(Branched from gnat)功能,并且我们还打开了一堆警告,在我们编译的某个时刻,它给了我们错误消息:

warning: use of this unit is non-portable and version-dependent

如果您还要求编译器将警告视为错误, ( -gnatwe) 您应该在找到它们时编译失败。

于 2013-02-22T11:01:43.113 回答