Classic Computer Magazine Archive COMPUTE! ISSUE 146 / NOVEMBER 1992 / PAGE A23

SAS/C Development System, Version 6. (compiler) (Software Review) (Evaluation)
by Steve Tibbett

Since the early days of the Amiga, there's been a lot of competition among the companies who create C language compilers for the machine. In the early days, it was a battle between Manx's Aztec C and Lattice C. More recently, parent company SAS took over development of the Lattice compiler, and Matt Dillion's D.I.C.E. shareware compiler entered the market. The compiler wars that have resulted have given the Amiga three very good C compilers. But never have any of the compilers seen an update so dramatic as the jump from SAS/C 5.10b to SAS/C 6.

The SAS/C Development System, Versions 6 has everything you need to dive right into developing applications for the Amiga. The compiler supports both AmigaDOS 1.3 and 2.04, and the new Version 6 libraries are fully ANSI compliant, so you can write portable C programs, as well. An integrated environment--consisting of the SE editor, compiler, CPR debugger, SLink linker, and a host of utilities--gives you a complete development system that can be used from either the Workbench or CLI.

While all of these pieces were available in previous versions of the compiler, they've been improved for Version 6. If you used earlier releases, you'll notice that the names of many of the executables and libraries have changed. For example, LSE (which stood for Lattice Screen Editor) is now simply SE. The C language compiler itself, the core of the product, has been completely rewritten.

To compile a program from the command line, you type SC Program.c. To link it, too, just add the Link keyword: SC LINK Program.c. There are dozens of compiler options that you can add to the command line, but there are better ways than doing this manually every time you compile something. You can use SMake to build a makefile for your project, and then a complex program can have its parts compiled and linked together by simply typing SMake You can put compiler options into a file called SCOptions and copy a default compiler options file to the ENVARC: directory for options that you always want to set. There's also a friendly GUI-based program that you can use to create a compiler options file; SCOptions gives you buttons for every compiler option, as well as online help.

Using the Workbench environment is quite different. You run the SCSetup utility to add icons to the directory your project is in. Icons are created for functions such as editing files and building projects. If you double-click on a C source file, it will be loaded into the editor, where you can compile it by pressing F4. In the editor, pressing Ctrl-F4 brings up the SCOptions window. There's also a Build icon that will compile a multipart project (by invoking SMake) and a Debug icon to load the debugger.

If you want to keep the integrated environment but you don't want to use the SE text editor, you can use the SCMsg utility to integrate any ARexx-compatible text editor with the system. This program will pass compiler errors and warnings on to your editor. The package includes ARexx scripts which integrate TurboText and CygnusEd with SAS/C.

Professional programmers usually consider the speed of a compiler and the quality of the resulting object code to be the most important aspects of any language package. With SAS/C 6, time and code quality involve a tradeoff that you make at compile time. The compiler works fastest when you aren't using the optimizers or asking for debugging information in your code.

Even without the optimizers turned on, the Version 6 compiler does a competent job of generating code. It no longer generates LINK and UNLK instructions at the start and end of every function, for example. Turning on the Global Optimizer and the new Peephole Optimizer will work wonders for both the size and the quality of the generated code. An overly simple explanation of the Global Optimizer is that it figures out what your code is trying to do and then rewrites it. Trying to write a benchmark with the Global Optimizer enabled can be difficult; if a routine does nothing except, for example, count to a million, the optimizer may remove it entirely! The Peephole Optimizer simply looks at the code after the compiler has generated and optimized it; then it removes redundant instructions. Without the Peephole Optimizer, you will sometimes see meaningless instructions like MOVE. L D7, D7. The Global Optimizer does slow down the compiler significantly and can make your programs more difficult to debug, so it's best used only late in the development cycle.

The SAS/C system uses Commodore's new AmigaGuide hypertext system extensively for online help in the editor, in the compiler options selector, in the debugger, and from the command line. A complete online reference to the libraries is included, as well as help on all the compiler options, errors, warnings, and utilities.

SAS/C 5.10b uses precompiled headers for speeding up compilation. SAS/C 6 no longer has this option, but it has added Global Symbol Tables (GSTs). These are similar to precompiled headers, except that they can stay resident in memory between compiles. If the compiler encounters an #include and the included header file is in the GST, then the symbols in that header file are instantly available to the program. Since developing Amiga programs involves including many system header files, this option can knock many seconds of time off every compilation. A pleasant surprise is the HyperGST utility, which formats the GST information into a hypertext format that you can browse through using AmigaGuide.

A common problem when testing code is ensuring that you've tested every path through the code. The SAS/C 6 compiler helps out here with its ability to generate coverage information. The coverage report will show you which lines of your code have never been executed by analyzing a data file generated each time your program exits. To use this ability, you compile with the Cover option and link with the supplied covutil.o module.

There are many other new features, both major and minor. Among them are Initialization and Termination functions, which will be called before and after the main[unkeyable] routine, respectively. System library bases, such as Intuition-Base, are now automatically opened when used, even if you don't define them in your code. Compiler warning and error messages are much more descriptive, and there are more of them. A remote version of the CPR interactive debugger has been added for debugging programs that aren't system-friendly. CPR itself has undergone many enhancements, with MMU and Enforcer support and the new ability to debug shared libraries. Documentation has been completely rewritten; there are now more than 1200 pages of reference material included.

The SAS/C Development System, Version 6 is an excellent compiler with a good company behind it. SAS has brought some heavy artillery to the compiler wars; let's hope that the battle never ends.