There is a small problem i have
there is a small error that i didnt use to have with the boorland compiler
I'm using xcode these days and in my switch case
im trying to execute a function
(as you can see, the "main" function)

however it says that it is an implicit declaration of function "main"
and that it is invalid in C99

i cant begin to understand this error:(

in boorland i had a few problems but
it still ran
but i dont understand this error

by the way
although the function "main"
is the last function
it shouldnt be a problem as
i had used it in an if statement also before the function "main" was declared.

any help would be crazy awesome :)

Edited 3 Years Ago by mattboy64: wrong article type

main() is always the first function the program will execute - regardless of what order your functions are listed in. (At least, of the functions you can see. There are other functions that boot the program and prepare it's execution, but you never see them)

You MUST have a main() function, explicitly declared, nowadays. (Before this change, some compilers would create a main() for you if you forgot it. No more.)

Your program should have ONE main() function, and your program should NEVER call main(). main() should not call itself, nor should main be called from any other function. (That you can see).

Edited 3 Years Ago by Adak

should I make a seperate function IN the main
so that I can execute that function within the switch statement
since main() shouldnt be called

thanks soooo much by the way:)

however it says that it is an implicit declaration of function "main"
and that it is invalid in C99

I'm guessing your main is defined like this:


That definition uses a feature called "implicit int", wherein if a type is required such as in the return type of a function, omitting that type will result in the compiler assuming that you meant int. C99 removed that feature entirely, so now you have to explicitly specify the type:

int main()
This article has been dead for over six months. Start a new discussion instead.