Professional Web Applications Themes

Enabling C99 mode on XCode / gcc compiler - Mac Programming

Hello, I came across an error message "for loop initial declaration used outside C99 mode" when trying to compile a project with the following line in XCode: for(int i = 0; i < [someObj length]; i++) Searching through the net for answers, I found that this is because the gcc compiler wasn't set to C99 mode, thus the integer i has to be declared before the for loop: int i; for(i = 0; i < [someObj length]; i++) I'm wondering if there's any way to turn on this C99 mode in XCode? I recall that C++ and Java does not ...

  1. #1

    Default Enabling C99 mode on XCode / gcc compiler

    Hello,

    I came across an error message "for loop initial declaration used
    outside C99 mode" when trying to compile a project with the following
    line in XCode:

    for(int i = 0; i < [someObj length]; i++)

    Searching through the net for answers, I found that this is because
    the gcc compiler wasn't set to C99 mode, thus the integer i has to be
    declared before the for loop:

    int i;
    for(i = 0; i < [someObj length]; i++)

    I'm wondering if there's any way to turn on this C99 mode in XCode? I
    recall that C++ and Java does not have any problems with declaring
    variables inside the for loop.

    Greatly appreciate any advice. Thank you.

    N.
    Nicholas Guest

  2. #2

    Default Re: Enabling C99 mode on XCode / gcc compiler

    dans l'article google.com, Nicholas
    Tamara à ca a écrit le 7/06/04 4:54:
     

    Change your file extension from .m to .mm, I think it will enable c++.

    Eric Guest

  3. #3

    Default Re: Enabling C99 mode on XCode / gcc compiler

    ca (Nicholas Tamara) wrote in message news:<google.com>... 

    In Xcode bring up the info panel for your target, select the build
    tab, goto the C/C++ settings, and under the C Language Dialect choose
    C99 or GNU99. GNU99 adds some gcc specific features on top of the
    standard C99, you can read gcc's doentation to figure out what they
    are.

    Michael
    Michael Guest

  4. #4

    Default Re: Enabling C99 mode on XCode / gcc compiler

    In article <google.com>,
    ca (Nicholas Tamara) wrote:
     

    You can specify the proper GCC option (--c99, or something like that)
    under "additional compiler flags). The reason you don't need this for
    Java or C++ is that it's a feature of those languages. However, it's not
    a feature of "straight" C, and thus also isn't one of ObjC.

    Though, when the C99 standard was completed, they "back-ported" this
    C++ feature into C, and thus you can turn it on, if you want to.

    HTH,
    -- Uli
    http://www.zathras.de
    Uli Guest

  5. #5

    Default Re: Enabling C99 mode on XCode / gcc compiler

    Uli Kusterer <de> wrote in message news:<t-online.com>... 
    >
    > You can specify the proper GCC option (--c99, or something like that)
    > under "additional compiler flags). The reason you don't need this for
    > Java or C++ is that it's a feature of those languages. However, it's not
    > a feature of "straight" C, and thus also isn't one of ObjC.
    >
    > Though, when the C99 standard was completed, they "back-ported" this
    > C++ feature into C, and thus you can turn it on, if you want to.
    >
    > HTH,
    > -- Uli
    > http://www.zathras.de[/ref]

    Thanks to all. I was able to set the mode to C99 using the info panel. Thanks again.

    N.
    Nicholas Guest

  6. #6

    Default Re: Enabling C99 mode on XCode / gcc compiler

    Nicholas Tamara wrote:
     

    From the command line, the flag is -std=c99
    Peter Guest

Similar Threads

  1. Enabling Commenting Tools in embedded mode
    By drog@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 15
    Last Post: December 17th, 09:16 PM
  2. Replies: 0
    Last Post: August 15th, 03:18 PM
  3. Replies: 0
    Last Post: August 14th, 09:21 PM
  4. Replies: 0
    Last Post: July 21st, 10:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139