哪种方式最好让 S 成为 GSourceFunc?或者两者都不是?
typedef struct{
//...
}S;
struct MS{
//..
S *St;
};
static gboolean AL_Calback(gpointer data){
S *St = (S*)user_data;
St->Something = SomethingElse;
return TRUE;
}
int main (int argc, char *argv[]){
//...
MS *MainStruct = gnew0(MS, 1);
Mainstruct->St = gnew0(S, 1);
clutter_threads_add_timeout_full(G_PRIORITY_HIGH, 100, AL_Callback, MainStruct->St, NULL);
//...
}
或者像这样,
typedef struct{
//...
}S;
struct MS{
//..
S St;
};
static gboolean AL_Calback(gpointer data){
MS *MV = (MS*)user_data;
MV->S.something = SomethingElse;
return TRUE;
}
int main (int argc, char *argv[]){
//...
MS *MainStruct = gnew0(MS, 1);
clutter_threads_add_timeout_full(G_PRIORITY_HIGH, 100, AL_Callback, MainStruct, NULL);
//...
}
我尝试了其他方法,但无法使它们起作用。clutter_add_timeout 需要将指针作为参数。