Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » templates runtime einlinken

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
05.12.2004, 18:10 Uhr
dascandy



Ich bin Niederlander, also versuch ich gutes Deutsch zu schreiben. Weil mein Englisch viel besser ist habe ich auch ein Englischer ubersetzung aufgenommen.

Ich entwickle jetzt ein Betriebssystem und ich wollte ein moglichkeit darin mitnehmen womit man ein einfacher klasse gebrauchen kann in seiner Code, um sie danach beim laden von disk ein zu fullen mit wirkbarer code, den moglichst danach entwickelt worden ist. Dafur brauche ich den template-klassen zu kompilieren nach dem originalem programm, aber es ist mit normalen C++ compiler nicht moglich so etwas zu tun. Ich glaube das es moglich ist ein template so zu kompilieren das er in ein form von meta-code einverwandelt wird, um danach an ein beliebiger moment die code mit ein reeler klasse um zo wandeln das er normale code wird, um diese code danach zu linken mit den originellen programm. Die zwei teilen von den template denen nicht prekompiliert werden konnten seien den grossten von den parameter und die anrufen nach funktionen von den parameter. Diese zwei sind load-time an zu passen in meta-code, und ich glaube das es damit moglich ist. Habe ich recht, ist dies sogar einmal gemacht oder habe ich ein Denkfehler?

(excuzes-moi fur nicht kapitalizieren von viele worter, das ist mich nicht gewohnt )

---- Translation / Ubersetzung

I am developing an operating system and I would like to give it the ability to use a simple class or an interface in the code of a user, to later replace it with a real instantiation from a template class that might have been developed later. For that, I have to compile the template after the original program was compiled (since it was made last) and to link it in to the original one. With a normal C++ compiler this is impossible. I think it's possible to translate the template to a form of meta-code, so one can later take this code together with a normal class to fill in the missing bits (size of objects and function calls to the object) in order for it to be linked in at that point. Am I right, has this been made before or did I make a big mistake in thinking?


Vielen Dank, Thanks for help,
Peter
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
06.12.2004, 16:49 Uhr
virtual
Sexiest Bit alive
(Operator)


I try it in English...

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.
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.

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.

Kind regards,
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
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).
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: