PTC MKS Toolkit Knowledge Base

Product:MKS Lex and Yacc (None)
Keywords:truncarion, warning, compile
Category:General/Knowledge Base

Why do I get a large number of truncation warnings when compiling my output code?

You will get these warnings because some compilers are more strict about type conversions. MSVC++ 5.0+ is one of these. The two common types of assignments that cause these warnings (in large quantity) can be safely ignored:

In lex output code: Assigning the value ~0U to a unsigned variable.

In yacc output code: Assigning values between 32k and 64k to a short int.

To suppress these warnings with MSVC++ 5.0 add this line to the start of your Lex and Yacc output code:

#pragma warning( disable : 4305 )

This issue was fixed in the 3.3 release of MKS Lex & Yacc.