Xref: utzoo comp.lang.c:33282 comp.std.c:3839 Path: utzoo!attcan!uunet!samsung!dali.cs.montana.edu!uakari.primate.wisc.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!psuvax1!psuvm!ji8 From: JI8@psuvm.psu.edu (Dave Jeffery) Newsgroups: comp.lang.c,comp.std.c Subject: Returning error codes from a function Message-ID: <90303.114803JI8@psuvm.psu.edu> Date: 30 Oct 90 16:48:03 GMT Organization: Penn State University Lines: 35 We would like to write a function that returns a pointer to void (void *). In this function there are several conditions that can occur that would be considered an error. Rather than simply returning NULL we would like to return more detailed error information. Several ideas have been discussed but one that seems to have the most promise is to define several global void pointers and return them. Please note that this is in a multi-tasking environment where a global error code is not acceptable, and the overhead of passing additional parameters is too high. void *error1 = "error1"; void *error2 = "error2"; void *ourfun(int p1); main() { ... if (ourfun(10) == error1) ... ... } void *ourfun(int p1) { .... return error1; ... } Our concerns are: 1. Does this violate ANSI C ? 2. Is it portable ? In your replies, please site where in the ANSI C standard, or any other publication, this issue is clarified. ---- Dave Jeffery JI8@psuvm.psu.edu