Ecere SDK/eC Forums
https://ec-lang.org/community/
Print view

simple example of how to embed C in ecere
https://ec-lang.org/community/viewtopic.php?f=10&t=452
Page 1 of 1
Author:  amigojapan [ Fri Jul 29, 2022 8:05 am ]
Post subject:  simple example of how to embed C in ecere

Code: Select all

import "ecere"


class Form1 : Window
{
   caption = $"Form1";
   background = formColor;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   clientSize = { 320, 304 };

   //*** How to call a C function form ecere
   extern int myFunction(int val) {
      //C code in here
      return __GNUC__+val;
   }
   Label label1 { this, caption = $"label1", position = { 48, 24 } };
   Button button1
   {
      this, caption = $"button1", position = { 144, 72 };

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         int v;v=1;//value to send to C function
         int a=myFunction(v);
         char c[100];
         sprintf(c,"%d",a);
         label1.text=c;
         return true;
      }
   };
}

Form1 form1 {};
Author:  amigojapan [ Sat Jul 30, 2022 4:59 am ]
Post subject:  Re: simple example of how to embed C in ecere

my bad, I had gotten something confused, turns out all you need to do to run C is add a c file to the project, you do this by going to the project view and clickign add file from the context menu. then those files can just call C functions... easier than I thought!
All times are UTC-05:00 Page 1 of 1