Many subprogram declarations of GNAT Standard Library uses Pragma Inline in their specification files and I want to know how it work because other modules use only this specification during compilation and not body?
Asked
Active
Viewed 174 times
3
-
2See [ARM 6.3.2](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-6-3-2.html). – Simon Wright May 21 '22 at 18:47
-
3See also the [GNAT doc](https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/building_executable_programs_with_gnat.html) about inlining, esp. the `-gnatn` switch. – Zerte May 21 '22 at 21:35
-
1In C++, for the compiler to inline a function, its definition must be in a header file. In Ada, after all, when compiling a module, only the specification files of with'ed packages are used, while their definitions may not even exist yet? There is no mention of this in the section of the manual you mentioned. – Андрей Гриценко May 21 '22 at 21:59
-
1@Андрей Гриценко - This is indeed an interesting curiosity. The compiler must indeed be able to peek into the body to grab the actual implementation in order to inline it. If the body is not available (as source), then, AFAIK, inlining will not be possible although I'm not sure about the potential role of LTO here. – DeeDee May 21 '22 at 22:27
-
1Thank you! I found comprehensive information about it here: https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/gnat_and_program_execution.html – Андрей Гриценко May 21 '22 at 22:37
-
1You can [answer your own question](http://meta.stackoverflow.com/q/17463/163188), perhaps citing the sources mentioned above. – trashgod May 22 '22 at 12:13
-
2[This](https://github.com/gcc-mirror/gcc/blob/master/gcc/ada/inline.adb) may give some insight as to what GNAT takes into consideration when inlining. – Simon Wright May 24 '22 at 09:52