selecting compiler options? [message #629035] |
Sun, 26 September 2010 15:33 |
|
Hi -
I'm using Eclipse for a C++ programming class I'm enrolled in. I've completed my first assignment (which was actually just a C project, not C++), except that the compiler won't allow me to use the "bool" data type.
Somewhere deep in the tutorial, I seem to recall that I have the option to choose from a variety of compiler settings (or even different compilers) within Eclipse, but I can't locate that option.
Can someone please advise me on the best method to attack this issue? Thanks.
Oh: running OS 10.6.4; have the development tools installed, etc.
|
|
|
|
Re: selecting compiler options? [message #629230 is a reply to message #629073] |
Mon, 27 September 2010 14:19 |
|
Axel Mueller wrote on Sun, 26 September 2010 23:32 | The bool data type was introduced in C++. C does know nothing about "bool".
|
Really? Interesting...I was under the impression that some of the newer versions of C did support "bool." Thanks for the information.
|
|
|
Re: selecting compiler options? [message #629348 is a reply to message #629230] |
Mon, 27 September 2010 21:22 |
Eclipse User |
|
|
|
Originally posted by: bruce.ring.sbcglobal.net
The bool data type was added to C as part of C99. Try adding -std=c99 as a
compiler option. That is the option for gcc, depending on the compiler you
are using your option may be different.
"Michael Zimmers" <mzimmers@gmail.com> wrote in message
news:i7q8vh$7h0$1@news.eclipse.org...
> Axel Mueller wrote on Sun, 26 September 2010 23:32
>> The bool data type was introduced in C++. C does know nothing about
>> "bool".
>
>
> Really? Interesting...I was under the impression that some of the newer
> versions of C did support "bool." Thanks for the information.
|
|
|
Re: selecting compiler options? [message #629349 is a reply to message #629348] |
Mon, 27 September 2010 21:55 |
|
Thanks, Bruce. How do I add/change a compiler option within Eclipse? Is it a build variable?
And...I assume that I can keep a few different build settings around, in case I want to flip-flop between old C and C99. Is this typically done by creating new build configurations?
Thanks again.
|
|
|
Re: selecting compiler options? [message #629370 is a reply to message #629349] |
Tue, 28 September 2010 01:54 |
|
I went into Terminal and tried that compile option; same result. Perhaps my compiler (whatever comes with XCode) is really that behind the times?
I'm still interested in trying to manipulate compiler commands from within Eclipse, if anyone can help with that. Thanks.
|
|
|
Re: selecting compiler options? [message #629378 is a reply to message #629370] |
Tue, 28 September 2010 05:36 |
Eclipse User |
|
|
|
Originally posted by: bruce.ring.sbcglobal.net
I'm running the ganymede version of Eclipse where you set command line
options for the compiler by selecting Project, Properties, expanding C/C++
Build, and then clicking Settings. In the right pane, there are options for
the compiler and linker. I've put the -std=c99 option under the
miscellaneous category for the compiler in the past.
I'm running on Windows with the version of gcc that comes with Cygwin, so I
can't help you with XCode. You need to check the XCode documentation for its
corresponding setting. I can't believe that Apple would not support the C99
standard.
"Michael Zimmers" <mzimmers@gmail.com> wrote in message
news:i7rhno$qj1$1@news.eclipse.org...
>I went into Terminal and tried that compile option; same result. Perhaps my
>compiler (whatever comes with XCode) is really that behind the times?
>
> I'm still interested in trying to manipulate compiler commands from within
> Eclipse, if anyone can help with that. Thanks.
>
>
|
|
|
Re: selecting compiler options? [message #629574 is a reply to message #629378] |
Tue, 28 September 2010 18:31 |
|
Here's the command line:
Quote: | gcc -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -MMD -MP -MF"src/lab1.d" -MT"src/lab1.d" -o"src/lab1.o" "../src/lab1.c"
|
The compiler seems to accept the option (no error message like that), but I'm still getting an error when I try to use the bool data type. (It *is* just "bool var_name;" right?
Thanks.
|
|
|
Re: selecting compiler options? [message #629620 is a reply to message #629574] |
Wed, 29 September 2010 00:13 |
Eclipse User |
|
|
|
Originally posted by: bruce.ring.sbcglobal.net
It looks like you have to include <stdbool.h> as well. A quick and dirty
example:
#include <stdio.h>
#include <stdbool.h>
bool Yes = true;
bool No = false;
int main(void)
{
printf("%d\n", Yes);
printf("%d\n", No);
}
"Michael Zimmers" <mzimmers@gmail.com> wrote in message
news:i7tc4h$95p$1@news.eclipse.org...
> Here's the command line:
>
> Quote:
>> gcc -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -MMD -MP -MF"src/lab1.d"
>> -MT"src/lab1.d" -o"src/lab1.o" "../src/lab1.c"
>
>
> The compiler seems to accept the option (no error message like that), but
> I'm still getting an error when I try to use the bool data type. (It *is*
> just "bool var_name;" right?
>
> Thanks.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02338 seconds