Re: Const structure pointer as template argument
Re: Const structure pointer as template argument
- Subject: Re: Const structure pointer as template argument
- From: David Fang <email@hidden>
- Date: Fri, 30 Jun 2006 12:30:29 -0400 (EDT)
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).
Admittedly, the error messages in all 4.x versions of gcc could be
improved. May I submit your testcase to gcc.gnu.org?
HTH
David
David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
-- (2400 baud? Netscape 3.0?? lynx??? No problem!)
_______________________________________________
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