Printf (im Inneren C -Code) von Python in Google Colab aufgerufen. (Keine Ausgabe)Python

Python-Programme
Anonymous
 Printf (im Inneren C -Code) von Python in Google Colab aufgerufen. (Keine Ausgabe)

Post by Anonymous »

printf gibt nichts aus < /p>
Google Colab Cell: < /p>

Code: Select all

%%writefile my_functions.c
#include 
#include 
void my_void_func() {
printf("my_void_func called from C!\n");
}
< /code>

Kompilierung: < /p>
!gcc -shared -fPIC -o my_functions.so my_functions.c
< /code>

Hier geht Python -Teil: < /p>
import ctypes
libc = ctypes.CDLL("libc.so.6")
my_lib = ctypes.CDLL("./my_functions.so")
my_lib.my_void_func.restype = None
my_lib.my_void_func()

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post