Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!homxb!mtuxo!mtune!codas!ateng!chip From: chip@ateng.UUCP (Chip Salzenberg) Newsgroups: comp.lang.c Subject: Re: Variable function names Message-ID: <130@ateng.UUCP> Date: 21 Dec 87 18:54:57 GMT References: <973@russell.STANFORD.EDU> <47000027@uxe.cso.uiuc.edu> Reply-To: chip@ateng.UUCP (Chip Salzenberg) Organization: A T Engineering, Tampa, FL Lines: 27 In article <47000027@uxe.cso.uiuc.edu> mcdonald@uxe.cso.uiuc.edu writes: >>[Re generating code at runtime: (*(int (*)())&array[0])()] >Yes, I really mean it. I can't see why it cannot be specified to be generally >useful. I realize that, somewhere, there might be a machine that CAN'T, >realy, truly CAN'T, do what I want, but I have never seen one described to >me. The iAPX 286 can't do this in protected mode, which is the only useful mode for multitasking OS's. (Executable segments are not writable.) Look, if you're on a machine where executing data is allowed, you can just cast the data address to a function pointer and call the result: int (*func)(); char array[100]; ... func = (int (*)()) array; (*func)(); And if the C compiler won't even do the cast, use a union. As they say in Rome: Non perspiratum ("no sweat"). -- Chip Salzenberg "chip@ateng.UUCP" or "{codas,uunet}!ateng!chip" A T Engineering My employer's opinions are not mine, but these are. "Gentlemen, your work today has been outstanding, and I intend to recommend you all for promotion -- in whatever fleet we end up serving." - JTK