Path: ...!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Sat, 21 Sep 2024 07:35:48 +0000 From: Mark Summerfield Subject: how to make a macro work as a single line if stmt without braces Newsgroups: comp.lang.c MIME-Version: 1.0 User-Agent: Pan/0.149 (Bellevue; 4c157ba) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-ID: Date: Sat, 21 Sep 2024 07:35:49 +0000 Lines: 27 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-petjQUTKNRd+RoDRUDMJ5vkmUbnQdrtIwVWTh6wq4dBC7KzzRsyhugSq8eRFnNnV+PwCLP1UBJr9Uxz!DY5m2ObI4yfN6etNHy8XVRJCOh7Ov9jk2MJJGJj8rHwoD3qdYRUbpWbsbvQFPlNT8gmxWMoS3aUk!T/FKvzevmruIOPH1aY00eEpq4w== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Bytes: 1561 I have this macro: #define WARN(...) \ do { \ fprintf(stderr, "%s#%d: ", __FILE__, __LINE__); \ fprintf(stderr, __VA_ARGS__); \ } while (0); which I use like this: total++; if (failed) { WARN("failed because..."); } else ok++; I would prefer to be able to write this instead: total++; if (failed) WARN("failed because..."); else ok++; but doing so results in a compiler error: error: 'else' without a previous 'if'