Re: no previous prototype for function that is defined in header?
Re: no previous prototype for function that is defined in header?
- Subject: Re: no previous prototype for function that is defined in header?
- From: Marc Respass <email@hidden>
- Date: Tue, 25 Jan 2011 17:17:51 -0500
El Jan 25, 2011, a las 4:44 PM, Fritz Anderson escribió:
> On 25 Jan 2011, at 2:19 PM, Marc Respass wrote:
>
>> I have a .m file with nothing but functions in it. There is an accompanying header file with the function prototypes in it and I import the header in the .m. My target has -Wmissing-prototypes turned on and even though I have the header with the prototypes in it, I get "no previous prototype for" function. What am I doing wrong? I had to turn off the warning. I would prefer to keep it on but I don't know how to define my functions so that it will compile. Anyone know what's wrong?
>
> The next step is to bring an editor containing your .m file into focus, and select Build > Preprocess. You will, after some time, be presented with a huge file that shows what the preprocessor is actually passing into the parser. #ifed-out code will be absent. Are your prototypes there?
(replying to the list since I found the answer)
Thanks Fritz,
That was cool. I've never done that though I've read about it. My prototypes appear right above my function definitions. In fact, I added prototypes to my .m just to see what would happen but still got the error.
While I was responding, I was trying various things. I changed my function from foo() to foo(void) and that fixed it. I feel like such a schmuck. I even have my K & R book out but didn't find the answer. Maybe years of Java have replaced my C knowledge but I didn't realize that I had to have "void" in a method that takes no arguments. I checked the C Language Dialect and it's set to GNU99.
Thanks for the help.
Marc _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden