Return-Path: Delivered-To: apmail-incubator-celix-dev-archive@minotaur.apache.org Received: (qmail 6044 invoked from network); 14 Feb 2011 06:41:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Feb 2011 06:41:22 -0000 Received: (qmail 37266 invoked by uid 500); 14 Feb 2011 06:41:21 -0000 Delivered-To: apmail-incubator-celix-dev-archive@incubator.apache.org Received: (qmail 37240 invoked by uid 500); 14 Feb 2011 06:41:20 -0000 Mailing-List: contact celix-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: celix-dev@incubator.apache.org Delivered-To: mailing list celix-dev@incubator.apache.org Received: (qmail 37206 invoked by uid 99); 14 Feb 2011 06:41:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Feb 2011 06:41:19 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of a.broekhuis@gmail.com designates 74.125.82.43 as permitted sender) Received: from [74.125.82.43] (HELO mail-ww0-f43.google.com) (74.125.82.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Feb 2011 06:41:12 +0000 Received: by wwi17 with SMTP id 17so4489036wwi.0 for ; Sun, 13 Feb 2011 22:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=wbBQ7i57BLmBuElHDXp4VHkqP/Ki+upOARIWKDpKyRg=; b=FcZD50o4JCMkKUto9zQUWS43KkbJSNKaDZMIr0hZh+wI40K6knKJaGelyMK+upWH2m j19f+2//fmm/xeEc7m7O6KaXZmCngoOvmkJmfVteP7HJSo6pvY9cJnHD3DNhbnC9C52X ucJ+ZHX8/75jiyfHHT4dCth6WEBv9EfsC7n18= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Uqmp7+jtGmC/3eZ61FFMQ+GwXNNFp32wfThEgEYMiwjQ3b3kkA+Nj6RcOgxuEtN6Z+ GOn45it9KjpaCTnj/+T4norIHQeniywEouFnss2DlTupX8RZhkmu54N7zeM1Zx2YdO2D mZvGt9ue479xP5QcvpPjNpnVhaIQOteqZt1WY= MIME-Version: 1.0 Received: by 10.216.171.76 with SMTP id q54mr2707300wel.93.1297665650817; Sun, 13 Feb 2011 22:40:50 -0800 (PST) Received: by 10.216.48.145 with HTTP; Sun, 13 Feb 2011 22:40:50 -0800 (PST) In-Reply-To: <1297620084.5889.37.camel@Atomic> References: <1297620084.5889.37.camel@Atomic> Date: Mon, 14 Feb 2011 07:40:50 +0100 Message-ID: Subject: Re: Exception Handling in C From: Alexander Broekhuis To: celix-dev@incubator.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Bob, > Hello everyone, > > This is my first commit on this mailing list, so Ill briefly introduce > myself: I'm Bob Fels, software engineer in embedded real time systems. > For that I mainly use C, but I am also experienced in C++, Java, Python, > Perl, various assembly flavors etc. > > I am every interested in using a service approach in embedded software, > so Celix drew my interest. Good to see you here! > > switch (my_function()) > { > =A0 =A0 =A0 =A0case CELIX_RETURN_OK: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0case CELIX_RETURN_OUT_OF_MEMORY: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Do someting */ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0case CELIX_RETURN_DEVIDE_BY_ZERO: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Do someting */ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0default: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* This is bad, return value not expected = */ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > } > Don't forget to keep Celix simple however ;). > I agree with your idea to go for the easy solution. It will keep your > code simple. As I showed, even without libex you can still make the code > look very recognizable and if you really want to, with some defines you > can make it look more TRY-CATCHY. Good arguments, and I agree. I will start using the easy solution. This raises an other question though, in the example you gave, there is a dedicated CELIX_OUT_OF_MEM. Is it a good idea to redefine existing errors from errno.h into "own" errors? Or should errors be reused? Since I am looking at APR, I tried to see how they solved it, an apparently they wrap existing number into their own: >From https://svn.apache.org/repos/asf/apr/apr/trunk/include/apr_errno.h #ifdef ENOMEM #define APR_ENOMEM ENOMEM #else #define APR_ENOMEM (APR_OS_START_CANONERR + 7) #endif I think it makes more sense to have dedicated CELIX_ errors. This keeps the api clean in the way that the only reported errors are CELIX_ errors. Basically what APR also does. > > I hope this information/thoughts helps, > best regards, > Bob Fels This definitely helps! Looking forward to more remarks and your insight in embedded code/platforms! --=20 Kind regards, Alexander Broekhuis