• 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
Re: where have all the IVARS gone? (long time passing...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: where have all the IVARS gone? (long time passing...)


  • Subject: Re: where have all the IVARS gone? (long time passing...)
  • From: Sherm Pendley <email@hidden>
  • Date: Mon, 10 Jul 2006 11:48:32 -0400

On Jul 10, 2006, at 11:05 AM, Bill Bumgarner wrote:

On Jul 10, 2006, at 12:35 AM, Chris Suter wrote:

int ivar1;
int ivar1;

int main() {
  return 1;
}

% cc -Wall foo.c
%

No warnings. That seems like a bug to me.

It's not a bug. That's what the C spec. says it should do.

Neat. Why would anyone want that to happen?

Re-declaring variables happens more often than you'd think - you've probably even written that kind of code yourself, once you take preprocessor expansion into account.


Consider an opaque struct:

	struct foo; // This was #include-ed from a public header

	struct {
        	int a;
	} foo;

	int main() {
        	return 1;
	}

Also, consider a global that's declared in a header

	extern int foo; // #include-ed

	int foo;

It seems that the second declaration is, effectively, a no-op.

In the case of an ordinary int, yes. Seems like that allowing that case to compile might have been seen as kind of a necessary side- effect of allowing the above cases. I wasn't on the committee though, I'm just guessing. :-)


I have filed a feature request style bug against the compiler.

Good idea. Although it's technically legal C, and some multiple declarations are useful, the compiler could emit a warning when it finds such declarations when they're simply redundant.


sherm--

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >RE: where have all the IVARS gone? (long time passing...) (From: Vinay Prabhu <email@hidden>)
 >Re: where have all the IVARS gone? (long time passing...) (From: Bill Bumgarner <email@hidden>)
 >Re: where have all the IVARS gone? (long time passing...) (From: Chris Suter <email@hidden>)
 >Re: where have all the IVARS gone? (long time passing...) (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: convert Java or C Source code into Objective-c
  • Next by Date: Re: Re: Objects as keys NSMutableDictionary
  • Previous by thread: Re: where have all the IVARS gone? (long time passing...)
  • Next by thread: Re: where have all the IVARS gone? (long time passing...)
  • Index(es):
    • Date
    • Thread