• 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: ZeroLink: Perhaps better disabled per default?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ZeroLink: Perhaps better disabled per default?


  • Subject: Re: ZeroLink: Perhaps better disabled per default?
  • From: Andreas Grosam <email@hidden>
  • Date: Fri, 14 Oct 2005 13:18:10 +0200


On 14.10.2005, at 06:53, Marshall Clow wrote:

At 2:41 AM +0200 10/14/05, Andreas Grosam wrote:
While I fully agree with j o a r, I would like to mention, that this code snippet will compile without errors:

// file: foo.c

extern void bar(); // prototype

void foo() {
boar(); // typo
}

Don't expect errors when compiling with a C compiler. It even will not complain when the -pedantic or -Wmissing-prototypes flags are on.
This is because it is completely valid and legal code.
Sure, it won't link.

This may be true with gcc, but I have used C compilers (since the early 1990s) that would complain if they saw a routine that they had not previously seen a declaration or prototype for. (This behavior was controlled by a compiler switch, usually called "Require function prototypes" or something similar.)

This was not a CodeWarrior-ism, it predates CodeWarrior.

GNU C has a similar warning:
-Wmissing-prototypes (C only)
Warn if a global function is defined without a previous prototype declaration. This warning is issued even if the definition itself provides a prototype. The aim is to detect global functions that fail to be declared in header files.

This warning does not apply here, because within the function foo() a function will be *called* ( boar()) but not defined.
You see the differences?

Actually, the above code is valid and legal - its behavior is clearly defined in the C standard.
In C there is no warning flags which detects such usage. The linker will issue an error because of an undefined symbol _boar.


Maybe an improved indexer and (known) symbol coloring in Xcode may detect this errors.


Andreas

--
-- Marshall

Marshall Clow Idio Software <mailto:email@hidden>

It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.

 _______________________________________________
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: ZeroLink: Perhaps better disabled per default?
      • From: Mark Wagner <email@hidden>
    • Re: ZeroLink: Perhaps better disabled per default?
      • From: Markian Hlynka <email@hidden>
References: 
 >No compile errors for unknown functions? (From: Ando Sonenblick <email@hidden>)
 >Re: No compile errors for unknown functions? (From: Chris Espinosa <email@hidden>)
 >ZeroLink: Perhaps better disabled per default? (From: j o a r <email@hidden>)
 >Re: ZeroLink: Perhaps better disabled per default? (From: Scott Tooker <email@hidden>)
 >Re: ZeroLink: Perhaps better disabled per default? (From: Andreas Grosam <email@hidden>)
 >Re: ZeroLink: Perhaps better disabled per default? (From: Marshall Clow <email@hidden>)

  • Prev by Date: Re: Smooth scrolling
  • Next by Date: Re: ZeroLink: Perhaps better disabled per default?
  • Previous by thread: Re: ZeroLink: Perhaps better disabled per default?
  • Next by thread: Re: ZeroLink: Perhaps better disabled per default?
  • Index(es):
    • Date
    • Thread