How would you run C++-code if you don't either compile it into the binary itself, or a loadable module?
That said, the last C++-project was many years ago, when 1.3.24 was state of the art in eggdrop.. This was eggdrop2 (not eggdrop v2.xx), which did not make much progress and siezed development shortly after it was made official. Since then, development on the plain C eggdrop had continued for several years.
It has been ages since I messed with C++, so I cannot say how much work it would be to write an eggdrop-module in C++.
nml375 wrote:How would you run C++-code if you don't either compile it into the binary itself, or a loadable module?
I have no idea. That`s why I ask here.
I saw a very inspiring function in Delphi. If I got it right you can just write anywhere in your source
ASM
- ASM code here <
END ASM. Kinda cool if you really need asm.
Thought it`s possible third party tcl script to have a similar function in tcl too.
That`s why I am asking.
Modules seam kinda complicated. For debugging you always need to recompile the hole bot and if you think about sharing your work for endusers it`s kinda uncomfortable for them tool compared to tcl scripts.
What do you mean with 'compile it into the binary itself'? I can compile it.. Sure. But how to plug it into eggdrop? Recompile? :/
Tcl is a pure scripting-language, while C and C++ are programming languages...
Simply put, tcl is parsed at runtime, using "alot" of resources at runtime to interpret instructions. C (and C++) however, is compiled into machinecode, which is then used for execution.
Using assembler instructions in a scripting-language (asm) really is'nt practicle, as asm knows nothing of variables, fancy function names, etc. It basically is a mnemonic with a few parameters, usually being register address, memory address, or direct values. Languages such as tcl does'nt even allow you to find out the address where a variable is stored...
Most c/c++-compilers can handle assembly-instructions, and in many cases these can be intermixed with C and/or C++.
Now, for writing your own modules, checking the source of the various ones that comes with eggdrop is a good start, especially the woobie-module, as it's mainly there for demonstration purposes.
Roughly put however, you'll be expected to create a given set of functions that will be called upon certain events, such as when the module is loaded and unloaded. These should setup whatever needs to be done for your module to operate properly, such as registering functions and variables with tcl, creating/dropping bind-tables, etc... The ctcp-module makes quite a decent example on that.
GCC also supports assembler inclusion. Also running C++ code via TCL sounds a little strange, C++ isn't really made designed as interpreted language. Expect for the OOP there are only very few reasons to use C++ instead of C, not sure, but I believe I read somewhere that C even runs faster than C++, but might have been out of the context.
Then only thing that would make sense to "interpret C++" would be to compile to temp file and execute it ^-^, you could of course embedded code into a mainframe of source, to run headerless code, but I doubt that would make much sense, you would probably rather stick to development environment with interactive debugging etc..
I found now Tcl 8.4 has a load command (loads machine code) and Tcl 8.5 has also an unload command but didn`t try this with eggdrop yet. Sure you would still need to compile the source on a platform you want to run it.
Actually, loadable tcl modules has been around since 7.5 and possibly earlier (too long ago to remember). And yes, just like eggdrop modules, these has to be compiled into a loadable binary library prior being loaded.
In fact, this is used by many scripts using mysql-databases along with tclmysql.
Also worth noting, with eggdrop modules, as long as you do not touch any of "eggdrop's" files, but simply work with the files of your module, there would be no need to compile anything else than your module. In fact, make would'nt even try to rebuild your eggdrop as it would see all files and dependancies as unchanged, and thus not needed to rebuild.