www.gusucode.com > polyspace_code_prover 案例源码程序 matlab代码 > polyspace_code_prover/RunPolyspaceVerificationWithCodingRuleCheckingExample.m

    %% Run Polyspace Verification with Coding Rule Checking
% This example shows two different ways to customize a verification at the
% command-line. You can customize as many additional options as you want by
% changing properties in an options object or by using Name-Value pairs. 
% Here you specify checking of MISRA C:2012 coding rules, exclude headers 
% from coding rule checking, and generate a main automatically.

%%
% Create variables for source file path, include folder path, and results 
% folder path you can use for either method.
sourceFileName = fullfile(matlabroot, 'polyspace','examples', 'cxx', 'Demo_C_Single-File','sources','example.c');
includeFileName = fullfile(matlabroot, 'polyspace','examples', 'cxx', 'Demo_C_Single-File','sources','include.h');
resFolder1 = fullfile('Polyspace_Results_1');
resFolder2 = fullfile('Polyspace_Results_2');

%%
% Check coding rules with an options object.
opts = polyspace.CodeProverOptions('C');
opts.Sources = {sourceFileName};
opts.EnvironmentSettings.IncludeFolders = {includeFileName};
opts.ResultsDir = resFolder1;
opts.CodingRulesCodeMetrics.MisraC3Subset = 'mandatory';
opts.CodingRulesCodeMetrics.EnableMisraC3 = true;
opts.CodeProverVerification.EnableMain = true;
opts.InputsStubbing.DoNotGenerateResultsFor = 'all-headers';
polyspaceCodeProver(opts);
%polyspaceCodeProver('-results-dir',resFolder1);

%%
% Check coding rules with DOS/UNIX options.
polyspaceCodeProver('-sources',sourceFileName,...
     '-I',includeFileName, ...
     '-results-dir',resFolder2,...
     '-misra3','mandatory',...
     '-do-not-generate-results-for','all-headers',...
     '-main-generator');
%polyspaceCodeProver('-results-dir',resFolder2);