1

I have Encountered a strange "Warning 639: Strong type mismatch for type 'myip' in binary operation"

//file ip4.h
#include <IPAddress.h>   // which have ::ip::IPAddress

typedef ::ip::IPAddress myip;

myip myiptest;   // lint Warning 639 
::ip::IPAddress ip2;  // No lint warnings

The IPAddress.h file contains ::ip::IPAddress as follows

namespace ip
{
    struct IPAddress
    {
        IPAddress();
            ...
    };
}

i think there is no mismatching here! the PC-lint manual description for this error:

Check for strong typing when a value is Joined (i.e., combined) with another type across a binary operator.

So what's wrong?

update: after trials it appears that this warning raised only if the struct have a constructor , I think this explains things somehow when i declare an object it returns type ::ip::IPAddress not myip here is the mismatch. am i right?

cafce25
  • 15,907
  • 4
  • 25
  • 31
Abdurahman
  • 628
  • 8
  • 16
  • Can you show us some more code where you are actually using the variable `myiptest`? Here's a description of the source of your error -- the `-strong` option for lint -- in detail[http://www.gimpel.com/html/strong.htm]. – dirkgently May 07 '12 at 11:12
  • @dirkgently In this case it is not used except the line shown above, i checked the manual and i think i didn't violate a strong type rule ( type hierarchy , ...). – Abdurahman May 07 '12 at 12:17

0 Answers0