| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Jun 30, 2006, at 9:30 AM, David Fang wrote:
Hi, Instances that are passed as template arguments need to be declared with external linkage. In your case, you need to forward declare:
//------------ >8 snip 8<------------------- struct testStruct { long a; };
template <const testStruct* bob> class Helper { };
extern const testStruct constTestStruct; // EXTERN DECLARE!
const testStruct constTestStruct = {0}; // static initialization Helper<&constTestStruct> HelperConst; // binding argument
//------------ >8 snip 8<-------------------
Now this compiles on your first example.
Otherwise static linkage (of the instance argument) may result in multiple
definitions in different translation units with the same argument name,
referring to different types (because the symbols differ).
Aha. This makes sense, and your extern fix does indeed work.
Admittedly, the error messages in all 4.x versions of gcc could be improved. May I submit your testcase to gcc.gnu.org?
Agreed on the error message -- feel free to submit the testcase.
Thanks,
Ladd
_______________________________________________ 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
| References: | |
| >Re: Const structure pointer as template argument (From: David Fang <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.