How can i create a window on Linux. Can we call main function in C from CL using CFFI?

oleg harput olegharput at gmail.com
Fri Jul 3 09:53:22 UTC 2020


I tried to create a window on Linux(as i undestand you need to use
additional libraries in Linux)
so i tried to reach the this code using CFFI command

 (cffi:foreign-funcall "main" :void :void :int)

The C CODE:

#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
static void error_callback(int error, const char* description)
{
    fputs(description, stderr);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int
action, int mods)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GL_TRUE);
}
int main(void)
{
    GLFWwindow* window;
...
}
Which works in C. But SBCL gives me error message:

Execution of a form compiled with errors.
Form:
  (EXTERN-ALIEN "main" (FUNCTION INT VOID))
Compile-time error:
  during macroexpansion of (EXTERN-ALIEN "main" (FUNCTION INT VOID)). Use
*BREAK-ON-SIGNALS* to intercept.

 cannot use values types here
   [Condition of type SB-INT:COMPILED-PROGRAM-ERROR]

What does this error mean?
Can we call main function in C using CFFI?
Is there a solution?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20200703/96d74f55/attachment.htm>


More information about the ecl-devel mailing list