0

I've seen questions like this, but I don't know where to get the flag name or how to ignore it properly.

An example of where I'm running into an issue is with Reachability.h on line 76; I'm getting the warning message "Declaration of 'struct sockaddr_in' will not be visible outside of this function".

How would I go about getting the name of and ignoring this warning in the file? Would I put something like this:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsemantic-issue"
//reachabilityWithAddress- Use to check the reachability of a particular IP address.
+ (Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;
#pragma clang diagnostic pop

I've also been looking at these resources:

1

2

3

4

But I'm still at a loss.

I'm using LLVM 5.0

Community
  • 1
  • 1
RileyE
  • 10,874
  • 13
  • 63
  • 106

1 Answers1

1

If this Reachability class isn't your class, and you won't change the original code, then you have no choice.

Instead, if you want to change the original code, get the struct declaration and move to .h class. It will correct the warning.

And if you just want to remove warnings, use #pragma clang diagnostic ignored "-w", instead of "-Wsemantic-issue". It will remove all warnings between push and pop lines.

Bivis
  • 1,320
  • 1
  • 10
  • 24
  • I'm not exactly looking to solve the warning I mentioned, as it was only an example. There are cases where warnings cannot be solved, but are unnecessary, such as [in this case](http://stackoverflow.com/a/17054246/1292230) and a few other cases that I have. I just brought this up, as it is a fairly generic and well known class. I am hoping to get the question answered, if possible. As for this error, the `struct` is declared in an external library that would be excessive to declare in the .h file. – RileyE Jun 11 '13 at 22:51
  • So in your case, try to use #pragma clang diagnostic ignored "-w", instead of "-Wsemantic-issue". It will remove all warnings. – Bivis Jun 12 '13 at 19:07
  • I don't want to remove all warnings, though. And do I need the push and pop? – RileyE Jun 12 '13 at 19:12
  • 1
    Use push and pop, like you already using. It will only remove warnings between push and pop lines. Other warnings will keep showing – Bivis Jun 13 '13 at 01:33
  • Oh! Cool. I thought that may be how they worked, but I wasn't sure. – RileyE Jun 13 '13 at 01:41
  • OK! I edited the answer with this comments to make it correct and easy to reading. Cya! – Bivis Jun 13 '13 at 18:02