运行程序只会生成一个seg心理错误。 我之前在SCO系统上做过这个(旧的SCO在旧的天,而不是新的EVIL SCO ;-),但我不是记住这很难 这个很难。 任何进一步的指示赞赏。 奶酪, 马克。Very true! Stupid me.I''m still having trubbles ''though after fixing that stuff-up.The function.//---------------------------------------boolean new( sparqbeat * new_heartbeat )// Allocate heap space for the major application object// Return pass or fail condition{if ( new_heartbeat = malloc( sizeof( sparqbeat ) ) ){bzero( new_heartbeat, sizeof( sparqbeat ) ) ;new_heartbeat->life = __life ;// new_heartbeat->life = &__life ;// new_heartbeat->life = &(__life);return TRUE ;}else{return FALSE ;}}t.c: In function `new'':t.c:177: warning: assignment from incompatible pointer typeIn all instances.Running the program just produces a segmentation fault.I have done this before on a SCO system (good SCO in the olddays, not new EVIL SCO ;-), but I don''t remember it beingthis difficult.Any futher pointers appreciated.Cheese,Mark. > - Ian Collins。>--Ian Collins. ad******@addinall.org 写道: Ian Collins写道:Ian Collins wrote: >>>> >>> boolean(* logging)(char * log_name)=& __ logging;>>>boolean ( *logging ) ( char * log_name ) = &__logging; Boing!你不能在结构声明中做任务。 Boing! You can''t do an assignment in a structure declaration. 非常真实!愚蠢的我。 虽然在修好了这个东西之后我仍然有'trubbles'。 这个功能。 // --------------------------------------- boolean new(sparqbeat * new_heartbeat) //为主要应用程序对象分配堆空间 //返回传递或失败的条件 { if(new_heartbeat = malloc(sizeof(sparqbeat))) { bzero(new_heartbeat,sizeof(sparqbeat)); new_heartbeat-> life = __life; // new_heartbeat-> life =& __ life; // new_heartbeat-> life =&(__ life); 返回TRUE; } else { 返回FALSE; } } tc :在函数`new'': tc:177:警告:从不兼容的指针类型分配Very true! Stupid me.I''m still having trubbles ''though after fixing that stuff-up.The function.//---------------------------------------boolean new( sparqbeat * new_heartbeat )// Allocate heap space for the major application object// Return pass or fail condition { if ( new_heartbeat = malloc( sizeof( sparqbeat ) ) ) { bzero( new_heartbeat, sizeof( sparqbeat ) ) ; new_heartbeat->life = __life ; // new_heartbeat->life = &__life ; // new_heartbeat->life = &(__life); return TRUE ; } else { return FALSE ; } }t.c: In function `new'':t.c:177: warning: assignment from incompatible pointer type __life的原型是什么?在函数名称的开头使用''__'' 通常不是一个好主意。 - 伊恩柯林斯。What''s the prototype for __life? Generally not a good idea to use ''__''at the beginning of a function name.--Ian Collins. 这篇关于指向结构中的功能指针!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-08 07:38