← Back to team overview

maria-discuss team mailing list archive

Re: writing plugin with .net language (C#)

 

Hi,

With CDECL you are controlling the calling convention of the specified procedure or procedure when it is exported into the symbol table in the library.  That is, how symbols are named, how the stack is set up when jumping to the location of the routine in the library, etc.

It doesn't matter what the source code is written in, it all compiles to machine code, but the code has to know how to "talk" to the other code.  C/C++ can link to .so or .dll built from any language as long as the language exports the symbols with CDECL.  

The LINKER and the compiler both care about the calling convention because that is how the calls are executed in the library.

The Fastbit UDF exports the symbols that MySQL (written in C) using CDECL so that the dynamic loader can find and run the functions when you load the plugin.

--Justin

Sent from my iPhone

> On Oct 3, 2015, at 6:26 PM, Roberto Spadim <roberto@xxxxxxxxxxxxx> wrote:
> 
> hummm, it's like creating a ".dll" that export functions to other program call it? in this case your fast bit UDF functions export init/denit functions to mysql, right? and you are using C++ or C language when you use "extern"? i don't  know how compiler know if it's a C or C++ code
> 
> 2015-10-03 20:36 GMT-03:00 Justin Swanhart <greenlion@xxxxxxxxx>:
>> extern "C" {
>> 
>> Makes the function use CDECL calling conventions, which is equivalent to setting the .NET code to use CDECL calling conventions.  Any language that supports exporting symbols with CDECL calling conventions supports interoperating with C (it stands for C declarations aka C calling conventions).
>> 
>> --Justin
>> 
>> Sent from my iPhone
>> 
>>> On Oct 3, 2015, at 1:57 PM, Roberto Spadim <roberto@xxxxxxxxxxxxx> wrote:
>>> 
>>> sorry guys, i'm a bit confuse about c++ and c
>>> 
>>> i'm reading your fastbit udf code
>>> 
>>> at /fb_udf.h
>>> you have a C code, right?
>>> and at fb_udf.cpp a c++ code
>>> 
>>> you can mix c and c++ at the same code?
>>> 
>>> 
>>> at udf.h
>>> what this do?
>>> 
>>> "
>>> extern "C" { 
>>> "
>>> those functions should be undestood as "C" instead of "C++", or compiler should "export" those c++ function to "C" "code", or something related to C and namespaces ?
>>> 
>>> sorry it's not mysql specific but i'm not finding some C++ plugins examples
>>> 
>>> 
>>> 2015-09-21 13:43 GMT-03:00 Roberto Spadim <roberto@xxxxxxxxxxxxx>:
>>>> :D nice
>>>> what i will is something like:
>>>> 
>>>> 1) a plugin daemon that receive a tcp/ip connection with a double linked list "feed" (something like:  clear list, delete from position x to y, delete position x, insert at position x, update position x, move position x to y)
>>>> 2) save this feed to a myisam/spider/innodb/anyother engine (i'm thinking about using a mysql handler api) (i didn't check how it works, but i think handler sock use it)
>>>> 3) keep the double linked list at memory (reconstruct the list when server shutdown, maybe make some snapshots to avoid a long reconstruct, something like after X lines of feed, save the list, or after x minutes)
>>>> 4) a engine to read the double linked list at memory (i don't know yet how do this, but i will need some control about reading a shared memory, how to access this shared memory from daemon plugin using storage engine)
>>>> 5) a engine to read information about what daemon is doing (like 4)
>>>> 6) at same plugin daemon, create a tcp/ip connection to "export" the same feed to others users (just a proxy, not a big problem)
>>>> 
>>>> at top level i think i will have 1 daemon plugin + 1 storage engine plugin
>>>> 
>>>> i'm thinking about c++ 11 cause it have double linked lists, threads, atomic, sockets, and i dont need others libs (maybe i'm wrong, but that was my first impression about c++11)
>>>> 
>>>> 2015-09-21 13:34 GMT-03:00 Justin Swanhart <greenlion@xxxxxxxxx>:
>>>>> Hi,
>>>>> 
>>>>> My fastbit UDF use C++ 11 no problem.
>>>>> 
>>>>> https://github.com/greenlion/FastBit_UDF
>>>>> 
>>>>>> On Fri, Sep 18, 2015 at 11:52 PM, Sergei Golubchik <serg@xxxxxxxxxxx> wrote:
>>>>>> Hi, Roberto!
>>>>>> 
>>>>>> On Sep 18, Roberto Spadim wrote:
>>>>>> > guys , i'm still with doubts... but not more about c#, now about c++
>>>>>> > i was thinking about rewrite the code with c++
>>>>>> >
>>>>>> > my doubt is.... could i use C++ 11 ? or i will have problem with mariadb
>>>>>> > makefiles etc etc?
>>>>>> 
>>>>>> Sure, you  can use any language you want, C++11 is perfectly fine too.
>>>>>> cmake doesn't care.
>>>>>> 
>>>>>> Regards,
>>>>>> Sergei
>>>>>> 
>>>>>> _______________________________________________
>>>>>> Mailing list: https://launchpad.net/~maria-discuss
>>>>>> Post to     : maria-discuss@xxxxxxxxxxxxxxxxxxx
>>>>>> Unsubscribe : https://launchpad.net/~maria-discuss
>>>>>> More help   : https://help.launchpad.net/ListHelp
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> Roberto Spadim
>>>> SPAEmpresarial - Software ERP
>>>> Eng. Automação e Controle
>>> 
>>> 
>>> 
>>> -- 
>>> Roberto Spadim
>>> SPAEmpresarial - Software ERP
>>> Eng. Automação e Controle
> 
> 
> 
> -- 
> Roberto Spadim
> SPAEmpresarial - Software ERP
> Eng. Automação e Controle

Follow ups

References