2

I using the PCLint-Check 9.0L for a Project and got the current Error Message during a Lint-Check on all Lint-Object-Files(*.lob) of the Project:

  • W:\DevWA\src\Platforms_h\TSPlatforms.h Error 14: Symbol 'TS_IntDisableAsm(void)' previously defined (line 90, file W:\DevWA\src\Platforms_h\TSPlatforms.h, module TSPlatforms.c)

The PCLInt Help manual explains here: Symbol 'Symbol' previously defined (Location) -- The named object has been defined a second time.

But there exists only the following definition on the whole Project inside the TSPlatforms.h at Line 90:

#define TS_IntDisable()     TS_IntDisableAsm()
__asm TS_IntStatusType TS_IntDisableAsm(void)
{
 .set noreorder
! "r3"
    mfmsr   r3
    wrteei  0
 .set reorder
}

The TSPlatforms.h is included several times in different C-Files of my project, but the code is of course wrapped in a redefinition protection:

#if (!defined TSPLATFORMS_H)
#define TSPLATFORMS_H
...
#endif

Has anyone a hint for me to identify the error?

Thanks! HJ

xhienne
  • 5,738
  • 1
  • 15
  • 34
HoloJens
  • 67
  • 9
  • As an aside: Are you using MSVC? The docs seem to indicate that's invalid syntax for the `__asm` keyword (though it's been a long time since I have used it). The docs state the `__asm` must be followed by an assembly instruction or a brace: https://learn.microsoft.com/en-us/cpp/assembler/inline/asm?view=msvc-160 – Michael Burr Feb 11 '21 at 20:22
  • This is that main reason why we should never declare functions in h files if it can be avoided. Very mysterious and hard to solve linker errors. – Lundin Feb 12 '21 at 07:18

1 Answers1

3

My guess: the code TS_IntDisableAsm() is intended to be inlined. PCLint is not aware of that and thinks it is defined in multiple .c files and that there will be a conflict when everything will be linked together.

Adding a static keyword in front of your declaration should help.

xhienne
  • 5,738
  • 1
  • 15
  • 34
  • 1
    Or maybe the `inline` keyword? – Michael Burr Feb 11 '21 at 20:21
  • I assumed it is implied by `__asm` – xhienne Feb 11 '21 at 20:32
  • If `__asm` implies `inline` then I would register a bug with PCLint's vendor - assuming this problem is due to PCLint performing some sort of global checking (which PCLint appears to support). – Michael Burr Feb 11 '21 at 20:41
  • 1
    @MichaelBurr I really don't know. We don't know the compiler and I personally don't use PCLint. That's why I started my answer with "My guess..". Judging by the code, `__asm` seems to imply `inline`. If it does not, then that chunk of code has nothing to do in the .h file. – xhienne Feb 11 '21 at 21:40
  • The Complier was the WIndriver DIab-Compiler. And this worked! Thank you very much! – HoloJens Feb 12 '21 at 08:06
  • 1
    You're welcme @HoloJens. I added the "wind-river-workbench" tag, then. If I'm wrong, feel free to remove it. – xhienne Feb 12 '21 at 10:24