Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!nbires!vianet!devine From: devine@vianet.UUCP (Bob Devine) Newsgroups: comp.lang.c Subject: Re: how do I initialize a function pointer to be NULL ? Message-ID: <228@vianet.UUCP> Date: Tue, 15-Sep-87 15:59:25 EDT Article-I.D.: vianet.228 Posted: Tue Sep 15 15:59:25 1987 Date-Received: Thu, 17-Sep-87 06:06:18 EDT References: <197@tiger.Princeton.EDU> <27742@sun.uucp> <2236@emory.uucp> Organization: Western Digital, Boulder Tech Ctr Lines: 36 Keywords: NULLFUNC Summary: data pointers != function pointers In article <2236@emory.uucp>, platt@emory.uucp (Dan Platt) writes: > Actually, depending on the model (the IBM machines have a segmented > addressing scheme), NULL is defined as 0 if the memory is in small or > medium models, and is defined as 0L in compact and large models. > Since a module may need to be compiled several ways, rather than > checking the compile flags in the preprocessor, it's easiest to > just define it as #define NULLFUNC NULL, and including either > or (either having NULL defined) before the other > define. This is not right. You are confusing the NULL defined for *data* pointers with *code* pointers. The silly memory models can be shown as a 2-by-2 matrix : # of code segments one multiple +------------+------------+ one | SMALL | MEDIUM | # of data | 16bit code | 32bit code | | 16bit data | 16bit data | segments +------------+------------+ mult. | "un-named" | LARGE | | 16bit code | 32bit code | | 32bit data | 32bit data | +------------+------------+ So, using NULL will only give one column of the matrix. Let the compiler do the appropriate assignment. Or, if all functions are the same, you can use a define like: #define NULLFUNC (void(*)())0 Bob Devine [ Note that MSC does not name the commonly called "compact" variation.]