002
06.12.2004, 18:03 Uhr
dascandy
|
Since you answered in english, I will not translate these to german. I hope I'm not offending people / breaking with forum rules here...
Zitat: |
First of all, you cannot precompile Templates in a "MetaCode". If you compile a C++ template, the template parameters are expanded to concrete types and a non-meta but concrete class is compiled.
|
The only parts of the template class that are actually modified to fit the new type are the usages of the size (malloc, memcpy) and the usages of internal functions (operator+, fix_und_fertig()). If you keep those as a symbolic reference in what otherwise is a byte stream of code (after compilation) with references to symbolic variables that are the sizes of the object, and after knowing them (the postcompiler) do peephole optimizations on the resulting code, optionally inlining code, you should get the same result as with a normal compilation.
Zitat: |
Second, names of symbols (method and member names of classes) are not standardized in C++, thus if you compile your stuff with - lets say - g++ and compile an another piece with vc, the symbols wont match. The drawback is that you have only one compiler (version) you can work with.
|
That can be solved by choosing one mangling and modifying all other code to fit. Since it's for a new operating system, I have the option to choose my own mangling method, and I can require others to conform, either by force (you rewrite your functions) or by help (use this program on your (un)compiled code to make it work). I think I kind of agree with gcc, mostly because they're the biggest "free" compiler, but also because the method is quite sturdy. It hasn't structurally changed over the last 3-4 versions, afaik it hasn't changed since 3.0. Must admit I didn't check that too closely.
The SysV standard for mangling names claims to be /the method for mangling names in c++/, and gcc conforms. Isn't it the standard? It's advertised in all IA64 publications as the one and only.
Zitat: |
I guess that you are looking for some kind of plugin mechanism. The solution would be something like the realisation of the factory pattern, whereas the factory classes will be wrapped by functions with (standardized) C linkage and exported by your OS's API.
|
This would be used for compiling programs without actual template instantiations, in a way so that the STL would not be regarded as a "high-god that you cannot touch and is always perfect" but more as a real piece of code that can have flaws, and can be upgraded separately to better algorithms or better implementations. In a way, instant backporting new changes. I'm not sure whether this is a really good idea, but it more or less requires being technically able to separately compile templates. I'm not sure whether it's possible, that's why I asked. Whether it's a good idea is a second question, and in a way more for an ethical forum than a technical forum (although I'd probably bother you anyway). |