RE: Problems with templates ???
Stefan Seefeld <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <20DCDD8F0FCED411AC4D001083CF504501AA9892@MTL-EXCHANGE> |
> From: Serge Iovleff [mailto:[email protected]] > > thanks. Yes, your code exposes a bug in the current parser, > > so I submitted a bug report > (http://synopsis.fresco.org/issues/bug43). > > I'm working on a new implementation for symbol lookup, replacing > > the problematic code. However, I'll try to come up with a short-term > > solution, too, as the bug seems quite serious. > With synopsis v0.5 the result was correct : except the dummy > and prev... > but, I recall I use the option -Wp,-g in order to obtain this result. Yes, it's possible I messed things up over the last months. It's really a special case and the bug disappears if you either take out the inclusion of the templated function definitions or you put all class declarations on top. Else I'd probably run into it much earlier... Thanks for the hint, I'll compare with older versions to see what it does differently. As I said, symbol lookup is where it fails now and that is known not to work very well (though it shouldn't affect what declarations are translated into the AST). > > In a related note: you include the '.cpp' files containing > > your template function definitions. You may consider removing > > the 'using namespace' directives at the top of these files, as > > they pollute your global namespace, probably not quite what > you want. > > > > In fact with old version of gcc (and many other compiler) it was not > possible to pre-compile the implementation for template class > definition. It's still not possible, in fact I haven't seen a single compiler that precompiles templates. I always put them into headers. > Thus I had to include the impementation in the declaration and then to > include the resulting file in the program using the template class. > > If the namespace STK is used for the declaration of "Myclass, > in the implementation I don't want to write STK::MyClass, > thus I think taht the 'using namespace' directive is not misplaced. It is, because any file including 'Array.h' expects to find the definition of 'STK::Array', but as at the end you throw in a 'using namespace STK' it means that all files including 'Array.h' will end up with an 'Array' type in the *global* namespace. The 'using' declaration isn't restricted to the file it appears in ! And, more dangerously, you have a 'using namespace std', too... Regards, Stefan