Using Console Mode
Console mode is discussed in clause 2.3 of the Janus/Ada manual. Console mode requires a special version of the runtime, and this needs to be set up in your project.
If most or all of your applications are going to be console mode (rather than GUI applications), then you probably would want to set the default link to console mode. If this is done, the compiler will automatically use the console mode runtime library with any NEW projects.
To change the default link, run the following command:where D:\Ada95 is your compiler directory.Jmanager Add_Default (D:\Ada95\Rts\Console, JNT_RTS_CONSOLE)
For reference, the command to set the default link for GUI programs isand to make Claw the default for programs:Jmanager Add_Default (D:\Ada95\Rts, JNT_RTS)assuming that D:\Claw is the directory where Claw is installed.Jmanager Add_Default (D:\Claw\Object, CLAW)
If you only want to use console mode for a few programs, with most being GUI programs, change the project's link. For a new project, this can be done by manually creating the project, then manually creating the appropriate link.
To create a new project named "New_Project" in the current directory:Note: If you are using JawsII, the project must be named "Default".Jmanager Add_Project (., New_Project)
To create a link to the console runtime for New_Project:where D:\Ada95 is the directory Janus/Ada is installed in, as above.Jmanager Add_Link (., New_Project, D:\Ada95\Rts\Console, JNT_RTS_CONSOLE)
Similarly, to create a link to the GUI runtime for New_Project:or to Claw:Jmanager Add_Link (., New_Project, D:\Ada95\Rts, JNT_RTS)Jmanager Add_Link (., New_Project, D:\Claw\Object, CLAW)
Warning: Run only ONE of these commands for any particular project!!
If creating console mode programs inside of Jaws, be sure to set the Jaws project to use console mode. (You will find this in the project options).
8-Character Name Limit in JAWS II
Q. I'm getting file not found errors when running Bind in JAWS II. My source file is named My_Test.Adb and the main subprogram is named My_Test_Main.
A. The Janus/Ada Binder (Jbind) requires the full name of the main subprogram, while the SDK tools must only be given the first 8 characters. Unfortunately, JAWS II doesn't know this. (We've submitted it as a bug to the supplier, hopefully it will be fixed in the next version of JAWS II). The only workaround is to insure that your source name and main subprogram name match, and are 8 or fewer characters long. This only needs to be done to your main subprogram; other packages can be named as needed. This is not a restriction when using Janus/Ada from the command line.
Printing with Janus/Ada 95 for Windows
Q. I would like to print from a simple program. I used Text_IO to open the "Prn" file (and various other names), but I always get a Name_Error exception or an ordinary file is written to. I'm running Windows 95. How can I print using Text_IO?
A. Unfortunately, the Windows 95 support for file printing is uneven. You can always print via the Windows printer support, but this is very complex. (Claw simplifies that somewhat, but it still is messy.) Printer support via Text_IO does work, but you probably will have to experiment with your machine to get it to work. (In the following, we assume you have a printer installed on your machine. If there is no printer installed in Windows 95, you'll have to do that first! Check the Windows 95 help file for information on doing that.)
If your printer is directly connected to your machine, the technique you tried should work. That is, open a Text_IO file with the special name "Prn". Then, just use Text_IO to write to the file. Note that most laser printers don't print until you eject the page, so it is usually a good idea to include a New_Page at the end of your printing.
If that doesn't work, you probably have a network printer. Windows does NOT support the special "Prn" file name for network printers. An attempt to open it will raise Name_Error. In order to print to a network printer, you will need to specify the network name of the printer. The easiest way to find the network name is to open the printers settings folder (found under "Settings" on the start menu); right-click on the printer icon; select "Properties"; select the Details page. Under "Print to the following port", there should be something like "\\ignitor\hp-laserjet". ("ignitor" is the name of the machine, "hp-laserjet" is the name of the printer on that machine.) Use that name (in the example, "\\ignitor\hp-laserjet") in place of "Prn". That will send the output directly to the printer.
This procedure will only work on a particular network, unfortunately. You could also try capturing a port such as LPT1 (see the Windows 95 help for instructions), and writing to that. We haven't been able to get that procedure to work for us, but perhaps your results will vary.
It should be pointed out that some printers simply cannot handle printing ordinary text. Such "Windows-only" printers can only be printed to using the complex Windows GUI procedure. Hopefully, you don't have one of those.
Using the Jaws II Library command
Q. The libraries menu in Jaws II is either greyed out or seems to show the files in the root of my hard disk. Why doesn't it work?
A. Jaws II is a third-party product, and as such, we didn't understand all of the nuances of it. In particular, Jaws II requires a different setup for specifications than the installation of Janus/Ada uses. (We figured out the details of this by disassembling the Jaws II program.)
Therefore, in order to use the "Libraries" menu in Jaws II with Janus/Ada 3.1.1 or 3.1.2, it is necessary to rearrange some of the files in the Janus/Ada compiler directory. (Later versions of Janus/Ada should install these files into the correct place for Jaws II.)
After doing these steps, the "Libraries" menus in Jaws II should display appropriate files for each item.
- Using Windows Explorer, navigate to the Janus/Ada compiler directory (that is, the directory where you installed Janus/Ada).
- In that directory, create a new directory (folder) by selecting "File" | "New" | "Folder" from the menu. Type the name "specs" into the box.
- Select the new "specs" directory.
- Create five new directories in "specs", named "nt", "user", "adauser", "adagraph", and "std".
- Drag the following files from the "libs" folder (found at the same level as "specs") into "std":
CALENDAR.LIB CHAR.LIB COMM.LIB C_STR.LIB DIRECT_I.LIB GEF.LIB HANDLING.LIB INTER_C.LIB LATIN1.LIB MAPCON.LIB MAPS.LIB NRANDINT.LIB NRANDOM.LIB NUMERICS.LIB RENAMES.LIB SEQUENTI.LIB STRINGS.LIB STRINGSB.LIB STRINGSF.LIB STRINGSU.LIB TEXT_IO.LIB WTEXT_IO.LIB
- Drag the following files from the "libs" folder into "nt":
MS_LOW1_.LIB MS_LOW2_.LIB MS_LOW3_.LIB MS_LOW4_.LIB MS_LOW5_.LIB MS_LOW6_.LIB MS_LOW7_.LIB MS_WINDO.LIB MS_WIN_B.LIB MS_WIN_C.LIB MS_WIN_D.LIB MS_WIN_O.LIB MS_WIN_P.LIB NT_CONSO.LIB NT_CORE.LIB NT_ERROR.LIB NT_EXCEP.LIB NT_IO.LIB NT_MEMOR.LIB NT_SERVI.LIB NT_TYPES.LIB
- Drag the remaining files from the "libs" folder into "adauser". The "adagraph" and "user" folders remain empty. If you like, you can copy the Claw specifications (Claw*.Ads) into "adagraph". "User" is intended for your personal set of reusable Ada packages.
Linking with Visual C++ 6.0
Q. I cannot get programs to link properly, even after following the directions in your manual. I have Visual C++ 6.0. Can you help?
A. [Note: This question and answer are specific to Janus/Ada 3.1.1; for Janus/Ada 3.1.2, use SDK_Chk to configure your system as described in the Installation Guide provided with your product.] The directions in the manual and on the disk with Janus/Ada 3.1.1 were designed for Visual C++ 4.0 through 4.2. As is typical with Microsoft, newer versions of Visual C++ shuffle all of the files around. Therefore is it necessary to modify Pathwin.Bat, or Autoexec.Bat to reflect the changes.
We will assume that Visual C++ is installed on C: into the default directory name, and that Janus/Ada is installed into C:\Ada95. If either are different, you should modify the suggestions below appropriately.
For Visual C++ 6.0:
Check the short name of the directory that Visual C++ is installed in by typing the following command in a MS-DOS window:
dir C:\Progra~1\Micro* then look in the resulting directory listing for "Microsoft Visual Studio". The short will be something like MICROS~1; if it differs on your system, use the value on your system in place of MICROS~1 below.
The PATH line in Pathwin.Bat should be changed to:
Path %PATH%;C:\Ada95;C:\Progra~1\MICROS~1\VC98\BIN; C:\Progra~1\MICROS~1\Shared~1\BIN
The INCLUDE line in Pathwin.Bat should be changed to:
The LIB line in Pathwin.Bat should be changed to: Set Lib=C:\PROGRA~1\MICROS~1\VC98\LIB
If you prefer, you can also make these changes to Autoexec.Bat, which will make them "permanent" for your system.
For Visual C++ 5.0:
The PATH line in Pathwin.Bat should be changed to:
Path %PATH%;C:\Ada95;C:\Progra~1\DEVSTU~1\VC\BIN; C:\Progra~1\DEVSTU~1\Shared~1\BIN
The INCLUDE line in Pathwin.Bat should be changed to:
The LIB line in Pathwin.Bat should be changed to:
If you prefer, you can also make these changes to Autoexec.Bat, which will make them "permanent" for your system.
Missing KERNEL32 function on Windows 95
Q. Until today, we have been developing, compiling, and testing our program under Windows NT. Today, we decided to try our program on a Windows 95 machine. First, we tried running the NT executable file (uucp.exe) directly. The program died in *very* early stages with 2 messagebox messages from Win95:
What is wrong with this???
- The UUCP.EXE file is linked to missing export KERNEL32.DLL:IsDebuggerPresent
A device attached to the system is not functioning.
A. This indicates that the "IsDebuggerPresent" routine is not defined. Pulling out the current MSDN CD, and searching it for "IsDebuggerPresent" quickly shows that Windows 95 does not support it at all.
Anyway, now the question is, why is it looking for this? There seem to be two possible answers:
- You are calling it somewhere. If so, CUT IT OUT! :-)
- You didn't link the program with /T to remove unused subprograms. In that case, an unused definition of the routine would cause Windows to look for it.
Replacing Janus/Ada 83 Exception_Info
Q. I was adapting the util package to implement a replacement for your Ada 83 Exception_Info routine, but it will not compile with the Ada95 forms. The identifiers are not defined (Info, Text_io etc.). How should Info be declared? What is the format of the string returned from Exception_Information?
A. Exception Infomation contains a complete walkback and other information, separated by CR-LF pairs. There is a LOT more information in the Ada 95 item than in Ada 83 Exception_Info. The format is not intended to used by program tools, so it wasn't designed with fields. What I would recommend is replacing the uses of Ada83 Exception_Info with Ada95 Ada.Exceptions.Exception_Information.
That's assuming that the primary use was to output a message. In that case, just outputting the string result from Ada.Exceptions.Exception_Information is much easier. (I.e. Put_Line (Ada.Exceptions.Exception_Information (stuff));
Note that your intended replacement routine for Util cannot work, because is does not have an Exception_Occurrence parameter. So no matter how you proceed, you're going to have to rewrite the calls.
when others => Util.Exception_Info (x, y, z, w);You would use:
when Info:others => Put_Line(Ada.Exception_Information (Info));
WMake Colors does not work
Q. I tried to run the WMake utility on colors like the installation directions said, but I get an error stating that the body of MS_WIN_BASIC.lib cannot be found. I have tried adding the path for the libraries to my autoexec.bat, but that did not help. Could you please let me know what I am doing wrong?
A. It looks to me like you have a problem with either your default link or with setting up the project file. Note that the default link is used only the first time a project is created, so if it is wrong, it stays wrong.
So, try deleting the _Janus.Prj file in the directory you're compiling to. Then retry. If that doesn't work, Delete the _Janus.Prj again, then check the default link:
Jmanager View_Default if it's not there or incorrect, reset it by JManager Add_Default C:\Jnt311\Rts\, Jnt_Rts (use your compiler directory, not C:\Jnt311\Rts). Or, perhaps the Rts install script failed for some reason. Run "JManager /D View_All C:\Jnt311\Rts" and verify that the project directory for the project name (stored in record #2) matches your compiler path. That is, if you installed into D:\Ada95, then the path stored in the file should be D:\Ada95\Rts.
If that fails, you probably ought to reinstall.
Does Janus/Ada support UNC filenames?
Q. Do the Janus/Ada tools understand UNC filenames (like: \\Server1\Janus\Ada95), or must a network drive be mapped to some file letter (like: G:\Janus\Ada95)?
A. I believe that the tools and runtime should support UNCs. (All of the tools are compiled with earlier versions of our compiler [except JAWS II]).
Q. We are having a problem where Ada95 is raising an Ada.IO_Exceptions.Use_Error error when we try to create a file using the 'open procedure' in an instantiated Direct_IO. Can use tell me under what circumstances use error is raised by open?
A. As it says in section 3.8.5 of the Janus/Ada manual, Direct_IO of non-simple types is not supported, and raises Use_Error. Use_Error is also raised for any error return from the operating system other than File not found error. In particular, sharing violations raise Use_Error.
Most of these cases have additional information in the exception message, which can be read with Ada.Exceptions.Exception_Message.
Using COrder with Janus/Ada 95
Q. I made the switch from Ada 83 to Ada95, and I don't quite see how to use COrder these days. One of my existing batches gives a "missing project name" error message.
A. In order so COrder would be consistent with the other tools, we had to change the existing "/P" option to "/N". Therefore, any existing "/P"s in old batches need to be changed to "/N". Adding a (new) /P and /R similar to those used by the compiler will also be a good idea (unless, of course, you aren't using those options with the compiler).
Q. If I run COrder on something in \examples, I'd like it to also recompile as necessary any changed stuff in \source, but seemingly the compiler's /p and /r options would have to be different in those cases. What am I supposed to do?
A. Assuming you are using the /Z option to compile files in linked libraries, COrder will put appropriate /P and /R options on the command line. You can look in the generated batch file to verify this before running it.
Q. I would like to get the arguments which are passed from operating system at the invocation. In C-Language, these would be "ARGC" and "ARGV". How can I get the invocation parameters?
A. You want to use the Ada 95 standard package Ada.Command_Line. See clause A.15 in the Ada reference manual for its definition.
If you are using Ada 83, you can get at the command line via the Util package. (See chapter 10 in the compiler manual). That package is also supported for Ada 95, but Ada.Command_Line should be used instead.
Janus/Ada Serial Number
Q. Your support people asked me for my Janus/Ada serial number when I called. I don't know it, how can I find it?
A. The serial number is always found on the label of the first floppy disk or on the card with the CD key. If the product was purchased directly from us, you'll also find it on the invoice.
However, we know most users put those things away immediately. Therefore, many of our programs report their serial number in some way. For Janus/Ada, the serial number is reported by Janus and JBind when you run them from the command line. You don't actually need to compile anything, just run either of them. You'll find your right below the R.R. Software copyright message.
This won't work if you have received a beta or patch version of the compiler from us; in that case the serial number will appear as RRS1-00000. In this case, you'll have to go back to the original disks or CD key.
Interfacing pragmas and "Unsupported Mode or Type"
Q. I'm getting the error message "Unsupported Mode or Type used for language convention" on a pragma Exported subprogram. The same subprogram works if I use pragma Import, and the parameter type is one declared in Interfaces.C. Is this a compiler bug?procedure My_Info (Data : in Interfaces.C.Char_Array); pragma Export (C, My_Info);
A. No, this isn't a bug. While the implementation advice in the Ada reference manual implies that this sort of parameter should be supported, it actually is impossible for pragma Export. [Note: The Ada 2012 Reference Manual corrects this mistake.]
The problem is that Interfaces.C.Char_Array is an unconstrained array type. That means that the object can be any length, with the actual bounds and length available via the array attributes (for instance, Data'Last in your example). However, C passes arrays as a pointer, without any length information. Therefore, the compiler has no idea how long the actual object is and therefore cannot determine the correct value to use for the Last and Length attributes. Since we can't apply meaningful values to these attributes, we have to reject the declaration of the subprogram.
There is no problem supporting this type for pragma Import (the item has stored bounds, but C doesn't need them, so we can just remove them), thus your example subprogram will work as an Imported routine, but will not work as an Exported routine.
A constrained array can be used in place of the unconstrained array:subtype My_Array is Interfaces.C.Char_Array (0 .. 1000); procedure My_Info (Data : in My_Array); pragma Export (C, My_Info);If you don't actually know the length of the C array when it is passed (for instance when the length is passed as a second parameter, or when it is a nul-terminated string), you can simply set the length to a very large value. However, in that case, you have lost the ability of Ada to detect out-of-range accesses to the array: any access beyond the end of the object could crash the program by scrambling memory. Use extreme care and extensive comments if it is necessary to do this.
Similar problems can arise for access types that designate an unconstrained array. For example:type My_Chars_Ptr is access all Interfaces.C.Char_Array; procedure My_Info (Data : in My_Chars_Ptr); -- Not supported. pragma Export (C, My_Info); function My_Data return My_Chars_Ptr; -- Not supported. pragma Import (C, My_Data);In both of these cases, we cannot determine the bounds to use for the designated object coming from C, so they are not supported. However, you can Import a procedure like My_Info, and Export a function like My_Data, as then we're removing information.
Interfacing pragmas and optimization
Q. When I compile a program using pragma Import to interface to C, I get an internal error from the optimizer:Parent getting bad kids Error caused by (4;#9;>#9;<#9) PSHFRP *ERROR* Internal expression error (6.2.2)A. This is a feature of Janus/Ada. ("Feature" meaning something unusual that's known and not expected to change in the near future.) The Janus/Ada optimizer assumes that calls follow the rules of Ada 95. If that's not true, an internal error like the one above may result. Unfortunately, the declaration of subprograms with convention C make such invalid (to the optmizer) calls.
The solution is to avoid turning on the basic-block optimizer (/Z2) in any unit that includes a pragma Import with convention C. You can use the other optimization flags, so setting optimization with /Z1/Z3/Z4/Z6/Z7/Z8/Z9 instead of /ZT will work. Units that don't contain pragma Imports for C can be optimized normally.
Note that this issue only exists for C convention Imports. If the convention is StdCall (which is much more common for Windows programs), optimization should work normally.
Unix Compatibility for Janus/Ada
Q. I have Red Hat Linux 2.0.36. Will Janus/Ada 95 for Unix work on this system?
A. Janus/Ada 95 for Unix conforms to the Intel ABI for Unix. Systems that are known to conform are SCO UNIX and older versions of Sun Solaris for Intel processors. Other systems claim to support the ABI, including some of the free systems. However, there are as many versions of Unix out there as there as there are computers -- we simply can't test them all. Therefore, we've created a simple compatibility test for Unix and Unix-like systems.
The test consists of a pair of test programs compiled with Janus/Ada 95 for Unix. Since the compiler is an Ada program compiled with Janus/Ada 95 itself, if the example programs work, it is very likely that the compiler also will work properly.
Click here to download the tqsort program, and here to download the ACATS multiply test. The files are both compressed executables; they are named .zip to fool our provider's web server to send them as binary files rather than text.
To test the Tqsort program:
If the program works, it will write a random list of numbers to standard output, sort them, write the sorted list, and finally the time taken.
- Download the tqsort.Zip file.
- Change the file name to tqsort.Z with the "mv" command: mv tqsort.Zip tqsort.Z.
- Decompress the file: uncompress tqsort.
- Make the file executable: chmod 755 tqsort.
- Run the file: ./tqsort
To test the ACATS multiply test program:
If the program works, it will display a series of messages ending with "Passed".
- Download the c45504a.Zip file.
- Change the file name to c45504a.Z with the "mv" command: mv c45504a.Zip c45504a.Z.
- Decompress the file: uncompress c45504a.
- Make the file executable: chmod 755 c45504a.
- Run the file: ./c45504a
We've provided two programs so that we can check exception handling separately from the normal operation of programs.
If both programs work as expected, then Janus/Ada 95 should work on your system. If they don't work, Janus/Ada 95 probably won't work. We'd be interested in your results, especially exactly how the programs fail (if they fail); send them to firstname.lastname@example.org.