How can I fix conflicting "main" functions that prevent Code Prover analysis from completing?

2 visualizzazioni (ultimi 30 giorni)
The code I'm trying to analyze with Code Prover has two "main" functions: a "throwaway" main in the project's main file and the actual main within code auto-generated by Simulink (different definitions between the two). With no efforts to fix the issue, Code Prover gives the error:
declaration of function "main" is incompatible with a declaration in another translation unit (functions have incompatible types or linkage).
I have tried renaming the unused main function with a preprocessing script to prevent the names from conflicting with each other, which allows the analysis to complete successfully, but severely limits the results due to "Procedure" coverage only covering 2% (as seen in the below screenshot of the Dashboard)
I have also tried replacing the unused main's definition to match the auto-generated one, which then just gives me the more general error:
function "main" already defined in another translation unit
Are there other ways to circumvent this problem?

Risposte (1)

Jordan Ross
Jordan Ross il 9 Gen 2017
Hello,
You were on the right track by removing one of the main functions since it is not allowed to have more than one. Also, it will lead to incompatible types since the main generated by Polyspace is not really a main but a stub function that invokes all of your functions in seemingly illogical order.
You can try the following:
  1. Do not generate a main when generating code from Simulink. You can do this by going into the Configuration Parameters and in the All Parameters tab search for "main". The setting you will want to disable is "Generate an example main program".
  2. Do not generate a stub main when doing the Polyspace analysis. You can set this by following the documentation provided at the following page: http://www.mathworks.com/help/bugfinder/ref/verifymodelgeneratedcodemaingenerator.html
Additionally, you can always try doing the analysis directly from the Simulink model. An example of this can be found in the following page: https://www.mathworks.com/examples/polyspace-/mw/polyspace_bf-ex43674797-generate-and-analyze-code

Categorie

Scopri di più su Troubleshooting in Polyspace Products for Ada in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by