IBM
Contents Index Previous Next



Source and Error References


A source reference is a reference from a generated SDL declaration to the corresponding original C/C++ declaration. Source references are placed in the generated SDL/PR file.

An error reference is also a reference to a declaration in the input header file, but is used to point out an error (or a warning) in that file. Error references are therefore printed as messages to the standard error stream or to the Organizer Log Window.

CPP2SDL uses the #SDTREF format both for source and error references. See SDT References for more about #SDTREF.

Source References

When CPP2SDL is executed from the Organizer, or from the command line with the -ref option set, the generated SDL/PR file will contain references to the input source files. Such a reference occurs just before a generated SDL declaration, and is on the form

/*#SDTREF(TEXT,filename,line)*/

where

A source reference is shown in Example 89 below.

Example 89 : Source references

/*#SDTREF(TEXT,input.h,226)*/
NEWTYPE S STRUCT
  a int;
OPERATORS
  get_a: S -> int;
ENDNEWTYPE S;EXTERNAL `C++';

Error References

Error references have a similar format as source references but with a column position added after the line number:

/*#SDTREF(TEXT,filename,line,column)*/

CPP2SDL prints error references when errors or warnings are found during the translation. They are output to the standard error stream (stderr) or to the Organizer Log Window depending upon whether CPP2SDL is executed from the command line or from the PostMaster.

Problems with error references may arise because of the preprocessor. Among other things, the preprocessor expands macros, and a typical problem is illustrated in Example 90 below.

Example 90 : Error References

File def.h:

#define init InitializingFunction

void init(undefinedType *, int);

If CPP2SDL translates this file, the following error message will be printed:

#SDTREF(TEXT,def.h,3,27)
ERROR 3200 Syntax error.

Here the syntax error occurs at position (3,11) in the source file, but because of the macro expansion of init to InitializingFunction, CPP2SDL will report the error at position (3,27) instead. Thus the column position is several characters off the target in the original file. When using the Organizer Log's Show Error function (see Show Error) to view the source of this error message, the cursor will be placed at int instead of at
undefinedType. CPP2SDL calculates both source and error references from the preprocessed source code, and this may lead to reference problems when macros are involved.


http://www.ibm.com/rational
Contents Index Previous Next