C# native interop

C code:

 #include <stdio.h>
  
  
 void say_hello_world()
 {
   printf("Hello world from C\n");
 }

Compile the above C code with clang as follows:

clang hello.c -dynamiclib -o libhelloworld.dylib

C# code:

using System.Runtime.InteropServices;

var a = Test.say_hello_world();
class Test
{

    [DllImport("helloworld")]
    public static extern int say_hello_world();
}

Output of C# code:

Hello world from C

Posted

in

by

Tags:

Comments

11 responses to “C# native interop”

  1. eiffeltower paris Avatar

    i really enjoy reading such a greate article, keep up the wonderful work, check out my site at eiffeltower-ticketparis.com

  2. 最佳Binance推荐代码 Avatar

    Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me? https://accounts.binance.info/register-person?ref=IXBIAFVY

  3. 创建免费账户 Avatar

    Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://www.binance.com/register?ref=IHJUI7TF

  4. linezolid cost canada

    linezolid cost canada

  5. what does sertraline do

    what does sertraline do

  6. dapoxetine and tadalafil

    dapoxetine and tadalafil

  7. binance Avatar

    Your point of view caught my eye and was very interesting. Thanks. I have a question for you.

  8. binance referral Avatar

    I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://www.binance.info/ES_la/register?ref=VDVEQ78S

  9. Binance推荐奖金 Avatar

    Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://www.binance.com/register?ref=IHJUI7TF

  10. lasix water pill generic

    lasix water pill generic

  11. binance Avatar

    Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me. https://www.binance.info/fr/register?ref=T7KCZASX

Leave a Reply

Your email address will not be published. Required fields are marked *