We use the gcc attributing in order to mark functions weak in libraries. That way projects including these libraries can overwrite the content of that weak function with custom content.
e.g. usage in a library:
void __attribute__((weak)) foo (void)
{
}
The codeprover (polyspace-code-prover-nodesktop) doesn't seem to understand this attribute, as it is gcc specific implementation.
Does codeprover provide some alternative syntax for this?
I can see a valid alternative, but that would be quiet intrusive for our libraries:
#ifndef NO_FOO_IMPLEMENTATION
void foo(void)
{
}
#endif
So what does codeprover support in order to mark a function as weak, over writable by other implementation.

 채택된 답변

Alexandre De Barros
Alexandre De Barros 2017년 8월 31일

0 개 추천

Hello,
when you write "The codeprover doesn't seem to understand this attribute", do you mean that you have a compilation error?
If yes, I can't reproduce it when selecting "gnu4.6" as the "compiler" in Polyspace (version R2017a).
What version of Polyspace do you use, and what is the value associated to the -compiler option?
Best regards,
Alexandre

댓글 수: 3

using R2016a here, and gnu3.4 dialect
I don't have a compilation error. Codeprover just seems to ignore this attribute and use the function as a normal (non-weak) symbol.
In the end the codeprover 'linker' complains about the symbol being defined twice.
file1.c, line 40: Error: procedure xxxxxx multiply defined
| previously defined at file2.c:20
Alexandre De Barros
Alexandre De Barros 2017년 9월 1일
A workaround is to make these functions static inside the Polyspace verification.
Hence, multiple definitions will be allowed.
Could you contact the support? They will tell you how to do that.
Best regards,
Alexandre
Stein Heselmans
Stein Heselmans 2017년 9월 6일
I guess those static function would more or less be the same as my proposed workaround (#ifndef NO_FOO_IMPLEMENTATION). I'ld rather go with that

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by