RosettaCodeData/Task/Call-a-foreign-language-function/PicoLisp/call-a-foreign-language-function-2.l

21 lines
365 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
/*
How to create the shared lib/so file:
gcc -c -Wall -Werror -fPIC duptest.c
gcc -shared -o duptest.so duptest.o -Wno-undef
*/
#include <stdlib.h>
#include <string.h>
extern char * duptest(char * str);
char * duptest(char * str) {
static char * s;
free(s); // We simply dispose the result of the last call
return s = strdup(str);
}
int main() {
}