Xref: utzoo comp.lang.c:33292 comp.std.c:3842 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c,comp.std.c Subject: Re: Returning error codes from a function Message-ID: <14284@smoke.brl.mil> Date: 30 Oct 90 22:48:07 GMT References: <90303.114803JI8@psuvm.psu.edu> Followup-To: comp.lang.c Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 22 In article <90303.114803JI8@psuvm.psu.edu> JI8@psuvm.psu.edu (Dave Jeffery) writes: > 1. Does this violate ANSI C ? No, it's okay. The most important reference is 3.3.16.1. > 2. Is it portable ? No, because pre-ANSI compilers generally did not support void*. Since these error coded are really char* anyway, why not just use char*. In fact a typedef would be nice: typedef char *ErrorCode; typedef const char ErrorDef[]; /* for unchanging constants */ #define NO_ERROR 0 /* or some other form of null pointer */ static ErrorDef error1 = "error1"; ... ErrorCode ourfun(args) { ... return error1; } There are all sorts of possible variations on this theme.