Vector Help

Reference Manual for PC-lint® Plus

20 Common Issues

20.1 Syntax errors when using Boost

The Boost headers utilize certain compiler-specific quirks related to variadic macros whose behavior does not always match that of PC-lint Plus (or other compilers) resulting in syntax errors. The issue can be resolved by suppressing Boost’s reliance of these quirks by adding the following options to your PC-lint Plus configuration:

   --uBOOST_PP_VARIADICS 
   --uBOOST_PP_VARIADICS_MSVC

20.2 Suppressing MISRA/AUTOSAR/CERT C/CWE messages from library/system headers

By default, PC-lint Plus emits error, warning, and info messages from user code and only error messages from library code. The coding guideline author files (au-misra2.lnt, au-misra3.lnt, au-autosar.lnt, etc.) enable relevant messages for both user code and library code (including system headers). If it is not desired to check library code for coding guideline violations, the options -wlib(4) -wlib(1) can be placed immediately after the author file is referenced. This raises and immediately lowers the warning level for libraries resulting in a suppression of all non-error messages from library code. Any non-error messages that you intend to enable for library code (e.g. via +elib ) should appear after these options.

20.3 Standard C++ keywords not recognized when using au-misra-cpp.lnt

MISRA C++ 2008 requires the use of C++03 and the au-misra-cpp.lnt file accordingly contains the option -std(c++2003) to set the C++ language version. In C++03 mode PC-lint Plus will not recognize keywords introduced in C++11 and later (including constexpr, decltype, noexcept, nullptr, and static_assert).

To employ MISRA C++ compliance checking using a later version of C++, you will need to override the language version by adding the appropriate -std option (e.g. -std=c++11) anywhere after au-misra-cpp.lnt is referenced.

20.4 Running pclp_config from Windows produces errors or no result

Running pclp_config with the –list-compilers option should result in a list of supported compiler families. If running pclp_config in this way does not produce any output, the pclp_config utility probably isn’t actually being invoked. If errors related to missing modules (i.e. regex or pyyaml) are produced, the modules either are not installed or are not installed for the version of Python being invoked. Depending on the version of Windows and the mechanism by which Python was installed, you may need to prefix the invocation of pclp_config with python, py, or the specific version of Python that is installed. Please contact support if you continue to encounter issued related to the use of pclp_config.

20.5 Resolving error 309 (#error directive encountered)

Error 309 is issued when a #error directive is reached while processing a header or module. This is a fatal error and PC-lint Plus will terminate after issuing the error. #error directives typically appear in header files to diagnose error conditions at preprocessing time. Almost all instances of this message are due to missing or incorrectly defined macros. The location provided with this message is where the #error directive appears and inspection of the surrounding source code should reveal the condition for which the directive can be avoided. A typical example will look something like:

   #ifndef SKIP_FEATURE 
   #if VERSION < 5 
   #error "Feature requires version 5 or greater" 
   #endif 
   #endif

The #error directive above will be reached if SKIP_FEATURE is not defined and VERSION is either not defined or is defined with a value less than 5. The #error directive can be avoided either by defining the macro SKIP_FEATURE or defining VERSION with a value of 5 or greater. After determining the appropriate macro and value, the -d option can be used to define the macro appropriately for PC-lint Plus, e.g.:

   -dSKIP_FEATURE

will define the SKIP_FEATURE macro and:

   -dVERSION=7

will define the VERSION macro with the value 7. The appropriate option should be added to your project configuration file. Another common theme looks like:

   #if defined(ARCH_ARM) 
   ... 
   #elif defined (ARCH_PIC) 
   ... 
   #elif defined (ARCH_PCS) 
   ... 
   #else 
   #error "Unknown architecture" 
   #endif

In this case the header expects a macro corresponding to the appropriate architecture to be defined. If none of the recognized macros are defined, the #error directive is reached. In this case, the solution is to use the -d option to define the correct architecture macro. Note that if you used pclp_config.py to generate a compiler configuration and a macro of this nature is missing, it may indicate that a necessary CPU target option used to compile your project was not provided to pclp_config.py through the –compiler-options option. If this is the case, it is preferable to regenerate the compiler configuration with the appropriate CPU target options rather than adding a macro definition manually.

20.6 Resolving error 330 (static assert failed)

Error 330 is issued when the condition of a static assertion evaluates to false. This is a fatal error and PC-lint Plus will terminate after issuing the message. Like #error directives, static assertions are employed to diagnose error conditions detected during compilation time. In most cases, a failed static assertion is due to incorrect type size configuration or a missing or incorrectly defined macro.

The location provided with this message is where the static assert appears and inspection of the corresponding predicate should reveal cause of the failure. For example:

   static_assert(VERSION >= 5);

will fail if the VERSION macro is defined with a value less than 5 and:

   static_assert(sizeof(long) == 8);

will fail if the size of the long type is not equal to 8.

In the first case, the macro can be defined with the appropriate value using the -d option, e.g. -dVERSION=5. In the second case, the scalar data size options can be used to inform PC-lint Plus of the correct type size of the target platform.

20.7 Resolving errors 305 (unable to open module) and 307 (unable to open indirect file)

Messages 305 and 307 are issued when PC-lint Plus fails to open the specified file. This can occur if the file does not exist or is not present in the locations PC-lint Plus is searching for it. Ensure that the file is correctly spelled. If the file does not exist in the directory from which PC-lint Plus is invoked, you will need to either specify the path of the file or use a -i option to specify the directory containing the file so that PC-lint Plus can find it.

If the file name reported by PC-lint Plus does not match the provided filename, you may need to surround the filename in quotes to prevent the shell from interpreting space or other special characters, see the below issue for more information.

20.8 Syntax errors when using options that contain spaces

When providing arguments to PC-lint Plus on the command line, you will need to surround arguments that contain spaces with double quotes to prevent your command interpreter from treating the spaces as an argument separator. For example:

   pclp -iC:/directory with spaces C:/lint/module with spaces.c

will produce an error from PC-lint Plus similar to:

   <command line>  3  error 305: unable to open module 'with' 
   with 
   ^

because the arguments provided to PC-lint Plus from the command interpreter are:

   -iC:/directory 
   with 
   spaces 
   C:/lint/module 
   with 
   spaces.c

PC-lint Plus will process the first argument (-iC:/directory) as an include directory and then try to open a file named with and fail with error 305. The correct way to pass these arguments to PC-lint Plus is to surround the arguments with double quotes:

   pclp64.exe "-iC:/directory with spaces" "C:/lint/module with spaces.c"

When appearing inside of an indirect (.lnt) file, filenames containing spaces should similarly be surrounded with double quotes. Options, such as -i options should be enclosed with double quotes with the first quote character appearing after the - or + that starts the argument, e.g.:

   -"iC:/directory with spaces"

as arguments starting with a double quote are assumed to represent a file name, not an option. See also Options on the Command Line and Quoted Options and Arguments .

20.9 Resolving error 322 (unable to open include file)

Message 322 is issued when PC-lint Plus fails to open a file specified by an #include directive. PC-lint Plus searches for header files in several places including search directories specified by -i options, any directories specified by the INCLUDE environment variable, the directory of the including file if the fdi flag option is enabled, and the directories of the current #include stack if the fsi option is enabled.

In most cases, the solution is to add a -i option with the directory of the specified file to cause PC-lint Plus to search the correct directory. Note that if the #include directive contains a relative path, the directory specified by the -i option must be the location from which this relative path can be accessed. For example, if the #include directive looks like this:

   #include "inc/header.h"

and the full path of the header.h file is C:/sys/inc/header.h, the correct -i option would be -iC:/sys, not -iC:/sys/inc.

20.10 Syntax errors when using options containing parentheses on the command prompt

Parentheses have special meaning in some command interpreters and need to be quoted to suppress their meaning. For example, invoking PC-lint Plus from the command line as:

   pclp -os(results.txt) test.c

may result in an error reported by your command interpreter as:

   syntax error near unexpected token `('

There are several possible solutions. You can quote the argument to suppress the special behavior of the parentheses:

   pclp "-os(results.txt)" test.c

In most cases PC-lint Plus will accept square brackets in place of parentheses within options. Since most command interpreters do not attribute special behavior to square brackets, the command can be written as:

   pclp -os[results.txt] test.c

although quotes will likely be necessary if your option contains space characters. Finally, you can place the option in an indirect (.lnt) file.