• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
struct "declared with greater visibility than the type of its field" warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

struct "declared with greater visibility than the type of its field" warning


  • Subject: struct "declared with greater visibility than the type of its field" warning
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 26 Oct 2009 15:59:02 -0700

I'm trying to get rid of a pesky compiler warning which makes no sense to me. I'm wondering whether it's a GCC bug. The C++ code in question looks like this:

struct EditorInternalCommand { ...... };

static const CommandMap& createCommandMap()
{
struct CommandEntry { const char* name; EditorInternalCommand command; };
...


When compiled, this last line produces the warning:

warning: 'WebCore::createCommandMap()::CommandEntry' declared with greater visibility than the type of its field 'WebCore::createCommandMap()::CommandEntry::command'

Apparently the compiler thinks CommandEntry is an externally visible symbol while EditorInternalCommand is not. The -fvisibility=hidden flag is set, though, so all of these symbols should be hidden. Certainly there's no way that a single-use struct type declared only internally to a single function would be visible.

Weirdly, the simplest way I've found to get rid of the warning is to move the CommandEntry declaration up above the beginning of the function. Why would this make it less visible?

I'd be willing to just move the declaration and shrug it off, but my code-reviewer is being a stickler and doesn't want us to change this without knowing what the actual issue is and why this fixes it.

[This is using GCC 4.2, build 5574, with Xcode 3.1.3.]

—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: struct "declared with greater visibility than the type of its field" warning
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: Re: unknown required load command 0x80000022
  • Next by Date: Re: Getting a handle on inf
  • Previous by thread: Re: Project templates & encoding
  • Next by thread: Re: struct "declared with greater visibility than the type of its field" warning
  • Index(es):
    • Date
    • Thread