![]() |
![]() |
![]() |
![]() |
![]() |
Error Handling
The input headers to CPP2SDL have in many cases been compiled with a C/C++ compiler previously, and it should then be relatively uncommon that CPP2SDL will have to issue any error messages. However, differences in language support, and inappropriate preprocessor settings, are common sources for error reports also from input files that otherwise are perfectly correct.
If CPP2SDL finds an error in the input, a message will be printed that briefly describes the reason for the error.
The format of printed error messages are described in Source and Error References.
CPP2SDL performs a complete syntactic analysis of the input C/C++ code, and syntax errors are reported as shown in Example 142 below.
int f(};
conts int i = 7;% cpp2sdl syn.hParsing C/C++ input...Syntax errors found. Cannot perform SDL translation.#SDTREF(TEXT,syn.h,1,7)
ERROR 3200 Syntax error.#SDTREF(TEXT,syn.h,2,7)
ERROR 3200 Syntax error.2 errors and 0 warnings.CPP2SDL will proceed with semantic analysis only if no errors were found during the syntactic analysis. The semantic analysis that is done by CPP2SDL is not complete according to the C/C++ standards, but only a limited number of semantic tests are performed:
- The type of variables, constants, typedefs, functions, function arguments, actual template arguments, and base classes are checked. If a type is undeclared, or if it depends on an undeclared type1, an error message will be issued.
- The actual arguments of a template instantiation are checked against the formal arguments of the template definition. If there are too few or too many actual arguments, or if there are type mismatches between actual and formal arguments, an error message will be issued.
template <class U, int d> class S {
public:
U arr[d];
};
typedef unknown T; // T depends on undeclared typeconst unknown a = 3;
T f(int, char);
S<T, 3> var;
typedef S<> t1; // Too few actual arguments
typedef S<char, 5, 5> t2; // Too many actual arguments
typedef S<int, int> t3; // Argument type mismatch% cpp2sdl -errorlimit 10 sem.hParsing C/C++ input...Translating C/C++ to SDL...Generating SDL...#SDTREF(TEXT,sem.h,11,9)
ERROR 3263 Illegal instantiation of template 'S'.#SDTREF(TEXT,sem.h,10,9)
ERROR 3263 Illegal instantiation of template 'S'.#SDTREF(TEXT,sem.h,9,9)
ERROR 3263 Illegal instantiation of template 'S'.#SDTREF(TEXT,sem.h,8,3)
ERROR 3261 The type 'T' is undeclared, or is depending on an undeclared type.#SDTREF(TEXT,sem.h,7,3)
ERROR 3261 The type 'T' is undeclared, or is depending on an undeclared type.#SDTREF(TEXT,sem.h,6,15)
ERROR 3261 The type 'unknown' is undeclared, or is depending on an undeclared type.#SDTREF(TEXT,sem.h,5,17)
ERROR 3261 The type 'unknown' is undeclared, or is depending on an undeclared type.#SDTREF(TEXT,sem.h,1,33)
WARNING 3211 Cannot translate template declaration. The declaration will be ignored.7 errors and 1 warnings.Note that the command line option -errorlimit can be used to set a limit for the number of errors to report before terminating a translation.
1One example of such a type dependency is when the source type of a typedef type is undeclared. Usages of the typedef type will then be considered to be undeclared.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |