Fix Polyspace Compilation Errors About Unknown Function Prototype
Issue
Polyspace® verification can fail during the compilation or linking phase with an error message such as the following even if your source code compiles using your regular build commands.
the prototype for function 'myfunc' is unknown
To determine the data types for such functions, Polyspace follows the C99 Standard (ISO/IEC 9899:1999, Chapter 6.5.2.2: Function calls).
The return type is assumed to be
int.The number and type of arguments are determined by the first call to the function. For instance, if the function takes one
doubleargument in the first call, for subsequent calls, the software assumes that it takes onedoubleargument. If you pass anintargument in a subsequent call, a conversion frominttodoubletakes place.
Possible Solutions
Automate Analysis Configuration
The compilation phase of a Bug Finder or Code Prover analysis emulates your actual compilation using the source files and options that you specified during analysis. To make sure that the sources and Polyspace analysis configuration accurately reflect your actual compilation, create the Polyspace project or options file from your compilation or build command. For more information on creating from build command, see Configure Sources and Build Options in Project for Polyspace Analysis and Testing.
If your build command is not supported for automatic project creation, you might be creating a project manually. If you encounter the error during manual build of a project, try to trace the error to one of the following causes and apply appropriate fixes.
Check for Missing Files
Check if the source code you provided contains the function prototype.
For instance, the function might declared in an include file that Polyspace cannot find. If you #include-d the include file in your source code but did not add it to your Polyspace project, you see a previous warning:
Warning: could not find include file "my_include.h"
To check if the function prototype is missing, search for the function declaration in your source repository. If you find the function declaration in an include file, add the folder that contains the include file. For more information on specifying include folders, see Include paths (-I).
Check if Function Declaration is Hidden by Preprocessor Macros
Check if the function declaration is unavailable because of a preprocessor macro that is undefined during Polyspace analysis.
For instance, if the function declaration is in a header file, the file might be conditionally compiled using macros that are not defined in the Polyspace configuration, resulting in Polyspace ignoring the header file.
Check the header file for #ifdef, #ifndef, or #if conditions around the function declaration. Check whether the macros in these conditions are defined in your Polyspace project.
In the Polyspace Platform user interface, add your macros in the Preprocessor definitions field in the Build tab of your project configuration.
On the command line, use the
-Dflag to define macros.
For more information on the option, see Preprocessor definitions (-D).
See Also
Include paths (-I) | Preprocessor definitions (-D)