<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 31, 2011, at 8:12 AM, Larisse Voufo wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br>Folks --<br><br>This has had me puzzled for a while, and I could use an answer asap.<br>I am implementing concepts in Clang and seem to be missing a crucial piece of understanding, either of C++, or of Clang. <br>Basically, I have gotten mostly everything else implemented and working fine to the extend that I want them to, except for concept members instantiation (?).<br>
<br>Basic Example:  instantiation.cpp<br>----------------------<br><br><span style="font-family: courier new,monospace;">concept B<typename T> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  void f(int) { }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">concept_map B<int> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  void f(int) { }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">template<typename T></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">requires (B<T>) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">void func(T a) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//    f(a);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    f(0);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">int main(int argc, char **argv) </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{ </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    int i=0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    func<int>(i); </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br><br>Compilation:  clang++ instantiation.cpp -o example<br>
----------------------<br>It seems to be failing at link time, with the following error message:<br><br><span style="font-family: courier new,monospace;">Undefined symbols:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  "__ZN1B1fEi", referenced from:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      __Z4funcIiEvT_ in cc-MXLAc6.o</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ld: symbol(s) not found</span><br><br><br>Any idea? Anyone? <br>1) At which point are functions marked for instantiation?<br></blockquote><div><br></div><div>Look for calls to Sema::MarkDeclarationReferenced throughout Sema.</div><br><blockquote type="cite">2 ) At which point are they instantiated ?<br></blockquote><div><br></div><div>At the end of the translation unit.</div><br><blockquote type="cite">
3) If instantiated, why would they not be visible by the linker? <br></blockquote><div><br></div>Probably because the template instantiation mechanism couldn't find the definition of B<int>::f(int).</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">       </span>- Doug</div></body></html>