0

Ada is still new to me, so I am trying to find my way around the GPS IDE. I asked another question earlier, but I think this problem has precedence over that one, and may be at the root of my trouble.

When I compile, I am getting a long list of *warning: source file ... not found"

In my .gpr file, I have listed all of the spec and body source files and use the following naming scheme:

package Naming is
   for Casing               use "mixedcase";
   for Dot_Replacement      use ".";
   for Spec_Suffix ("ada")  use "_s.ada";
   for Body_Suffix ("ada")  use "_b.ada";
end Naming;

What is odd it the error messages all look either like this:

warning: source file "xxx_b.adb" not found

or this

warning: source file "xxx.adb" not found

Note that neither of these (xxxb.adb or xxx.adb) conform to the file specs, which should end with .ada.

Can someone explain what is going on here?

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
Jim
  • 5,940
  • 9
  • 44
  • 91
  • Unless you've got a complex build environment, why not just use the GPS Project Wizard to set up your project file? That's always sufficed for me. – Marc C Feb 14 '13 at 19:18
  • Started over with the wizard. That fixed this problem. It didn't fix the problem associated with my other question, but this is progress. – Jim Feb 14 '13 at 20:20

3 Answers3

1

I'm 99% sure that the problem is one of the ones I mentioned in answer to your other question: GNAT does not normally support more than one compilation unit in a file. I got exactly the behaviour you describe with GPS and these files:

james_s.ada:

with Jane;
package James is
end James;

jim_s.ada:

package Jim is
end Jim;
package Jane is
end Jane;

The error message on compiling james_s.ada says it can't find Jane_s.ada, but when I ask GPS to go to the declaration of Jane it takes me to the "correct" line in jim_s.ada.

You could use gnatchop to split jim_s.ada, but it doesn't understand project files or naming conventions; you probably want to keep the existing names for the code that works, so you'd rename gnatchop's output as required.

However! to my great surprise, it turns out that GNAT does support having more than one compilation unit in a file, provided package Naming in the project file tells it about each unit in the file:

package Naming is
   for Casing use "mixedcase";
   for Dot_Replacement use ".";
   for Spec_Suffix ("ada") use "_s.ada";
   for Body_Suffix ("ada") use "_b.ada";
   for Spec ("Jim") use "jim_s.ada" at 1;
   for Spec ("Jane") use "jim_s.ada" at 2;
end Naming;

It's up to you whether to do this or to bite the bullet and use gnatchop, either on the multi-unit files or on the whole source tree.

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • You recommendation to use the **for Spec** in *package Naming* seems to be working. – Jim Feb 20 '13 at 19:31
1

First off, this isn't an Ada problem, its a Gnat problem. Other Ada compilers have no problem with the file names you are using.

However, Gnat is rather unique in that it expects there to be only one program unit (package body, package spec, stand-alone routine, etc) per source file. This is because it is also rather unique in that it expects to be able to find the source code for any program unit just by knowing that unit's Ada intentifier. Most other Ada compilers maintain some kind of library file that maps file names to program units, and you have to register all your files into it. (Whereas your typcial C compiler just leaves the problem of finding files for all your code up to the user entirely).

Generally the easiest thing to do with Gnat, the way that will cause you the least trouble, is to just use its default file naming convention (and of course don't put multiple program units in a single file.

If you already have some existing Ada code (perhaps developed for another compiler), the easiest way to import it into Gnat is typically to run the gnatchop tool on it all. So that's what I'd suggest you try.

T.E.D.
  • 44,016
  • 10
  • 73
  • 134
  • You (and Simon) may be right that this is a problem with GNAT. Knowing that the code has already been released, it must compile correctly under the right circumstances. Do you have any reference to the GNAT specification that point out this difference? – Jim Feb 18 '13 at 17:29
  • The last paragraph of [chapter 2.1 of the GNAT User Manual](http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Source-Representation.html), and [chapter 13](http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Comparison-between-GNAT-and-Conventional-Ada-Library-Models.html). (BTW, it would have helped if you'd said that it had already been released!) – Simon Wright Feb 18 '13 at 22:26
1

From GPRbuild User's Guide:

Strings are used for values of attributes or as indexes for these attributes. They are in general case sensitive, except when noted otherwise [...]

Based on this, I believe you have to use "Ada" instead of "ada" as index for Spec_Suffix and Body_Suffix. I currently do not have access to the tools for testing this, so I suggest to just try it out.

flyx
  • 35,506
  • 7
  • 89
  • 126