1

Good morning,

I am trying to use Reachabily libraries and when I try to compile I always obtain the same error:

error: invalid conversion from 'BOOL' to 'NetworkStatus'

This is produced in:

BOOL retVal = NotReachable;
if((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect))
{
    retVal = ReachableViaWiFi;  
}
return retVal;     // error: invalid conversion from 'BOOL' to 'NetworkStatus'

I just saw this post : How to compile specific files in objective-c++ and the rest of the project in objective-c but it does not work.

I made a new proyect only with this libraries and all works perfect and I think that the problem could be the others linkings flags: -lstdc++ -all_load

Could you help me with this?

Thank you very much.

Community
  • 1
  • 1
damacri86
  • 295
  • 3
  • 13

1 Answers1

3

Your method should return a NetworkStatus. I think your variable retVal should not of type BOOL but of type NetworkStatus. In fact, setting ReachableViaWiFi on a BOOL could already be considered a bug.

Eiko
  • 25,601
  • 15
  • 56
  • 71
  • Thanks for the answer! Finally I make a cast it works perfect :) – damacri86 Jul 01 '11 at 10:32
  • 1
    @damacri86 Why are you casting and not just setting the variable to be the correct type? – Nick Bull Jul 01 '11 at 10:51
  • @damacri86 I highly recommend what @Nick Bull says... make the variable the correct type instead of assigning to a wrong type in the first place. – Eiko Jul 01 '11 at 13:12
  • Well those are Reachablity libraries and I don't want to change them. They usually works, but I probably have one special flag that is making the problem. Thank you very much :) – damacri86 Jul 01 '11 at 15:55