www.riscos.com Technical Support: |
|
ToANSI is a desktop tool which provides an easy interface to the ToANSI program that Acorn C/C++ installs in your computer's library. The ToANSI tool constructs command lines and passes them to the ToANSI program. ToANSI helps convert program source written in the PCC style of C to program source in the ANSI style of C. PCC is the UNIX Portable C Compiler, and closely follows K&R C, as defined by B Kernighan and D Ritchie in their book The C Programming Language.
ToANSI enables you to write (with care) programs that can be automatically converted between the PCC and ANSI dialects of C, hence assisting you in constructing easily portable programs. The associated tool ToPCC makes approximately the reverse translations to ToANSI. For more details of portability issues, see the chapter entitled Portability. The changes that ToANSI makes to C source are listed in the ToANSI C translation below.
ToANSI is one of the non-interactive desktop tools, its desktop user interface being provided by the FrontEnd module. It shares many common features with the other non-interactive tools. These common features are described in the General features of the accompanying Desktop Tools guide.
ToANSI makes the following transformations to C source code or header text:
type foo(/* args */);
as
type foo(args);
This transformation is one which requires care in the use of ToANSI, as it can result in invalid C being uncommented.
type foo(a1, a2) type a1; type a2; {...}
are rewritten as
type foo(type a1, type a2)
...
Note that ToANSI performs only simple textual translations and is not able to reliably diagnose C syntax errors, which may produce surprising results, so it is best to use ToANSI only on code you already know compiles.
Since porting programs is usually a one-off process involving some experimentation, only direct use of ToANSI makes sense. You cannot use ToANSI from Make.
To start the ToANSI tool, first open the AcornC_C++.Tools directory display, then double click on !ToANSI. Its icon appears on the icon bar:
Clicking Select on this icon, or dragging a source file from a directory display to this icon, brings up the SetUp dialogue box, from which you control the running of ToANSI:
ToANSI has hardly any options for its use, so its interface is simpler than most of the other Acorn C/C++ tools.
The File writable icon is for the name of the description file to be processed. If you displayed the SetUp dialogue box by clicking on the ToANSI icon bar icon, you will want to fill this in by dragging a source file from a directory display to this icon before running ToANSI.
Clicking Menu on the SetUp dialogue box brings up the ToANSI SetUp menu, which owing to the simplicity of ToANSI only has a single Command line item:
Clicking Menu on the ToANSI application icon on the icon bar gives access to the following options:
For a description of each option in the application menu see the chapter entitled General features of the accompanying Desktop Tools guide.
Running ToANSI displays any error messages in the standard text output window for non-interactive tools. If all goes well this window is empty:
As an example of using the tool ToANSI, open an empty SrcEdit text window and type the following example C source lines in it:
int foo(a, b) float a; double b; {}
Check that your Wimp$Scrap environment variable is set to a sensible file name, then save your new text file straight onto the ToANSI icon bar icon. Run ToANSI, then save the output text file straight onto the SrcEdit icon bar icon. The translated file looks like:
int foo(float a, double b) {}
For normal use you do not need to understand the syntax of the underlying ToANSI program's command line, as it is generated automatically for you from the SetUp dialogue box and menu settings.
The syntax of the ToANSI command line is:
toansi «options» «infile «outfile»»