I want to access the global variable of c in python. I can already use/access the functions of c in python using ctypes after making a .so file. Here's the C code :
#include <stdio.h>
int globalVar = 2;
void add_int(int num1,int num2){
globalVar = num1+num2;
fprintf(globalVar, "%d\n", );
}
float add_float(float num1,float num2){
return num1+num2;
}
and the Python Code:
from ctypes import *
adder = CDLL('/home/akshay/Desktop/ffmpeg/linking/addr.so')
adder.add_int(4,5)
var = c_int.in_dll(adder,"globalVar")
print "Sum of 4 and 5 = " + str(adder.add_int(4,5))
a = c_float(5.5)
b = c_float(4.1)
add_float = adder.add_float
add_float.restype = c_float
print "Sum of 5.5 and 4.1 = ", str(add_float(a, b))