1

I am working on a C project and since I have a mac, I am doing it in Xcode. I am using ANSI-C. Everything is working good so far, but I noticed Xcode allows me to compile and run when I do something like the following:

bool values[8] = { false, false, false, false, false, false, false, false };

As far as I know, there are no built-in boolean types in C, so I suspect Xcode is assuming I am writing C++. How can I disable this? I would like it to strictly allow only pure ANSI-C. Syntax highlighting is set to C, my file is called main.c I don't know what else can I do to disallow this?

Thanks.

Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
Alex Terreaux
  • 1,881
  • 5
  • 23
  • 39
  • 1
    i think i should help H2CO3 in his struggle against Xcode tag. this question has nothing to do with Xcode – Andrey Chernukha Jan 26 '14 at 17:57
  • Actually, the Xcode tag might be appropriate here. This question isn't strictly about C. It's about something normally not allowed in C that Xcode allows. – nhgrif Jan 26 '14 at 18:00
  • Alex, what include statements do you have? – nhgrif Jan 26 '14 at 18:01
  • Hi, I just have these two: #include #include – Alex Terreaux Jan 26 '14 at 18:02
  • I removed the allegro include and now the booleans are not allowed. So yeah, that was it. Thanks, if you want, post it as an answer and I will mark it as accepted. – Alex Terreaux Jan 26 '14 at 18:09
  • 3
    @nhgrif Xcode isn't a compiler, so is irrelevant here, and that's the point. Of course, most newbies don't get that distinction, so it's kind of understandable that so many people are confused on that point. – user1118321 Jan 26 '14 at 18:16
  • 1
    For this to be valid, it's enough to have something like `typedef enum { false, true } bool;` in any header. – Dmytro Sirenko Jan 26 '14 at 19:50

1 Answers1

1

Though your problem appears resolved by excluding allegro, I hope this is at least somewhat helpful regardless. For establishing specific C-dialect settings, do the following:

  1. Select your project in the solution explorer (the one with the blue Xcode app icon). The project -settings editor will open on the right.
  2. In the project-settings editor across the top is a series of clickable labels, including Basic All | Combined Levels. Select All and Combined.
  3. Roll down the settings configuration page until approximately 60% and you'll find a section called Apple LLVM 5.0 Language. Locate the setting: C Language Dialect.
  4. Choose your poison. For ANSI-only compliant C, choose ANSI C [-ansi]

Thats it.

WhozCraig
  • 65,258
  • 11
  • 75
  • 141