Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ILoveBASIC

macrumors newbie
Original poster
Mar 2, 2010
2
0
Hi, found this forum after searchin around the web tryin to figure out what my error messages meant.

Trying to follow a beginners guide to objective c, using Xcode
I made a new project under application - command line tool

Im tryin to make a simple function that i can call, just to do a basic maths calculation.
Spent hours trying to figure out what im doing wrong, but googlin error messages kinda brings up documentation with all sorts of tech speak :)
Ive copied my code below - it doesnt copy the error messages so ive typed them manually with **** around them
Sorry for being so dim, i could program pretty well in BASIC on my Atari ST, but guess things have moved on a bit! Im trying the easiest guide i can find, but i cant even get the second program running :-(
Any help really appreciated. Is my definition of the function in the wrong place? Again, sorry for being a bit dim.

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {


float circleradius =5;
float result;
result = circlearea(circleradius); ****error implicit declaration of function 'circlearea'****
return 0;
}

float circlearea(float wibble)
{ ****error conflicting types for 'circlearea'****
float thearea;
thearea = 3.14 * wibble * wibble;
return thearea;
}
 
Any help really appreciated. Is my definition of the function in the wrong place? Again, sorry for being a bit dim.

Yes. The compiler sees things strictly in the order they are in the file. Either move the function above main or put a function prototype for the function above main and leave the function where it is
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.