Cicada ---> Online Help Docs

Calling Cicada from a C program

Before we can use Cicada, we have to install it as a C library. Go to the download directory and run:


    ./configure && make && make install
   

Once installed, Cicada can be called from any C program. Here’s how:

The three arguments to runCicada() are:

  1. fs is an array of const Cfunction variables, each corresponding to a C function in our code that Cicada will need to call. Each Cfunction is 1) a string which is the function’s name in Cicada, followed by 2) a pointer to a function in our C code of type ccInt f(argsType). For example:


        ccInt f1_in_C(argsType args) { ... }
        ccInt f2(argsType args) { ... }
        const Cfunction fs[] = { { "f1_in_Cicada", &f1_in_C }, { "f2", &f2 } };
       

    The C/Cicada names may be the same or different. Cfunction and argsType are defined in cicada.h.

  2. myScript is a C string that gives a script to run when Cicada starts up. For example:


        char *myScript = "run(\"ThingsToDo\")";    // i.e. ThingsToDo.cicada
       

    If we don’t want to run a predefined script, we can just pass an empty string or NULL.

  3. runTerminal is a bool value and determines whether to run an interactive terminal. If it’s true, Cicada will open an interactive prompt after running myScript. If false, Cicada will exit after running myScript.


Prev: The Anagrambler    Next: C function declaration


Last update: November 12, 2025