Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Prevent warnings on forward struct declaration



Hi,

> typedef void (*SomeCompletionProcPtr) (struct SomeControlBlock *dInfo);
>
> typedef struct SomeControlBlock
> {
>   --- more stuff here ---
> }
> SomeControlBlock, *SomeControlBlock;
>
> So I have a struct and one of its variables is a pointer to a function whose
> parameter is a pointer to the struct.
> The forward declaration (with "struct" in the param list) works, but Xcode
> generates a warning:
>
> warning: its scope is only this definition or declaration, which is probably
> not what you want
> warning: 'struct SomeControlBlock' declared inside parameter list



	This doesn't answer your question about turning off the warning,
but FWIW, you could just forward declare:

	struct SomeControlBlock;

by itself before everything.
You can even typedef a forward-declared struct (before it's defined):

	typedef struct SomeControlBlock		SomeControlBlock;

(I'm assuming compiling "C" and not "C++".)

(and I just happen to be fixing things like this at the moment with
someone else's legacy source code...)

David Fang

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >Prevent warnings on forward struct declaration (From: Trygve Inda <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.