In what ways does C in Xcode differ from standard C?
In tutorials, I find many examples of code that return the error, "not availble in C99."
MacBook Pro, Mac OS X (10.7.5)
In tutorials, I find many examples of code that return the error, "not availble in C99."
MacBook Pro, Mac OS X (10.7.5)
clang the c compiler front end for LLVM, developed by Apple and used in Xcode is c99 compliant.
Is there any way to change this?
Seeing as I can't use normal C commands
change it to what?
I've never had a problem using anything in the C standard. Post the code that your are having problems with.
err...I could be incredibly stupid in this.
But many tutorials have things like
add (3,4);
and is this being used as a method or is it a function?
I feel stupid if I'm wrong here.
I probably am.
add(3,4) would (in all likelihood) be a function.
Remember in straight C there are no methods, methods while looking and behaving a lot like functions in C are a object oriented concept. You would deal with methods in objecitve-C for example but not in C
nothing to feel stupid about we all started at one time.
Okay, I admit my knowledge of everything's proper name's is shaky.
But why does this sort of function not work? Is it Xcode or my instructions, or perhaps something else?
Not work how?
Here's an example
#include <stdio.h>
main(int argc, char *argv[])
{
int add();
int x;
x = add(3,4);
printf ("x = %d\n", x);
}
int add(a,b)
{
return(a+b);
}
There is no add function in standard C. If a tutorial includes a function call like add(3,4), then either they have defined the function somewhere in the tutorial (like Frank Caggiano has done in his example), or they defined it in a previous tutorial and are simply assuming that you are using everything previous done (which is poor practice in my opinion...)
The mathematical functions provided in standard C are defined in the header file math.h. In the terminal, you can type "man math" to get teh manual page describing this header. Otherwise, the binary math operators +, -, etc, etc are used exactly as they would be in normal infix arithmetic.
I see where my mistake is occuring here. I was thinking the add() was a function on it's own.
C is a very interesting language.
Yes that would explain it. g_wolfman supplied a very good explanation.
Yes C is a very interesting language. Most people have a love it or hate it reaction to it. I love it. I find it a very nice concise language. You can learn its basics in an evening then spend the rest of your life exploring it.
If you want to learn it, take your time, read as much code as you can get your hands on and experiment.
regards
Thank you very much.
In what ways does C in Xcode differ from standard C?