Re: Const structure pointer as template argument
Re: Const structure pointer as template argument
- Subject: Re: Const structure pointer as template argument
- From: Ladd Van Tol <email@hidden>
- Date: Fri, 30 Jun 2006 10:57:36 -0700
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:
This email sent to email@hidden