This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [cxx-conversion] Support garbage-collected C++ templates

On 12-08-08 16:12 , Gabriel Dos Reis wrote:
hi Diego,

just a word on style in the documentation:

+template<typename T>
+void gt_pch_nx (TP<T> *tp)
+  extern void gt_pch_nx (T&);
+  /* This marks field 'fld' of type 'T'.  */
+  gt_pch_nx (tp->fld);

'extern' declaration at local scope if considered an extremely poor style in C++. Furthermore, it does not interact well with template instantiations and scope rules; plus it does not work well when the function actually has an internal linkage.

A proper way to bring a symbol into local scope is through
a using-declaration:

using ::gt_pch_nx;

I struggled a bit with this. I need to tell the template function that there exists a free function gt_pch_nx that takes a T&. This is not something that any header file has at the point of this declaration.

The function gt_pch_nx(T&) is declared and defined later in one of the gt-*.h files. This is another problem with the way that gengtype works today.

The using-declaration that you propose does not seem to give me what I want, though. How does it know that the function takes a T&?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]