• 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: Declarations in middle of C code?!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Declarations in middle of C code?!


  • Subject: Re: Declarations in middle of C code?!
  • From: Clark Cox <email@hidden>
  • Date: Sun, 4 Jan 2004 17:48:58 -0500

On Jan 04, 2004, at 17:24, Charles Srstka wrote:

> I thought this was not supposed to work in straight C code? This most
> certainly did *not* work with Project Builder under 10.2, but with
> XCode and gcc 3.3, I can write this code:
>
> #include <stdio.h>
>
> int main (int argc, const char * argv[]) {
> // insert code here...
> printf("Hello, World!\n");
>
> int foo = 1;
> char *bar = "foobar";
>
> printf("foo is %i, bar is %s",foo,bar);
>
> return 0;
> }
>
> and I get the output:
>
> Hello, World!
> foo is 1, bar is foobar
>
> I thought this was a C++ - only feature! Has this been added in gcc
> 3.3 or something?


The latest C standard (C99) allows this, while the previous C standard
(C89) did not.

--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Declarations in middle of C code?! (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: Declarations in middle of C code?!
  • Next by Date: Re: Declarations in middle of C code?!
  • Previous by thread: Re: Declarations in middle of C code?!
  • Next by thread: Re: Declarations in middle of C code?!
  • Index(es):
    • Date
    • Thread