Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Message-ID | <4E1EDFF6.5E4B@mindspring.com> (permalink) |
|---|---|
| Date | 2011-07-14 08:24 -0400 |
| From | pete <pfiland@mindspring.com> |
| Organization | PF |
| Newsgroups | comp.lang.c |
| Subject | Re: #define with semicolon |
| References | <ab0d55fe-25e5-482b-811e-c475aa6065c3@c29g2000yqd.googlegroups.com> |
cc wrote:
>
> Is it acceptable practice to have a #define with a semicolon in it,
> such as:
>
> #define SMALL 1;
>
> I didn't think it was, but a very good friend of mine claims it's
> perfectly acceptable if you want to prevent the #define from being
> used in an expression like if(SMALL).
The only macro construct that I'm familiar with,
which is designed to be a statement,
is this:
#define macro \
do { \
} while (0)
That gives you a compound statement
in which you can do various things,
such as defining objects etc..
But the semicolon is left out of the macro
so you are forced to have
the semicolon being obvious in code like this:
macro;
--
pete
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
#define with semicolon cc <scatnubbs@hotmail.com> - 2011-07-13 11:19 -0700
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-13 12:38 -0700
Re: #define with semicolon cc <scatnubbs@hotmail.com> - 2011-07-13 12:56 -0700
Re: #define with semicolon Dr Nick <3-nospam@temporary-address.org.uk> - 2011-07-13 21:09 +0100
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-13 13:30 -0700
Re: #define with semicolon Hallvard B Furuseth <h.b.furuseth@usit.uio.no> - 2011-07-14 13:03 +0200
Re: #define with semicolon Gene <gene.ressler@gmail.com> - 2011-07-14 05:27 -0700
Re: #define with semicolon Roberto Waltman <usenet@rwaltman.com> - 2011-07-15 10:54 -0400
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-15 09:05 -0700
Re: #define with semicolon Robert Wessel <robertwessel2@yahoo.com> - 2011-07-15 11:49 -0500
Re: #define with semicolon Noob <root@127.0.0.1> - 2011-07-21 15:31 +0200
Re: #define with semicolon "J. J. Farrell" <jjf@bcs.org.uk> - 2011-07-22 01:51 +0100
Re: #define with semicolon Harald van Dijk <truedfx@gmail.com> - 2011-07-13 13:51 -0700
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-13 14:01 -0700
Re: #define with semicolon Harald van Dijk <truedfx@gmail.com> - 2011-07-13 14:14 -0700
Re: #define with semicolon Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-13 17:10 -0600
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-13 16:20 -0700
Re: #define with semicolon Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-14 14:03 +0300
Re: #define with semicolon Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-07-14 01:22 +0100
Re: #define with semicolon Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-22 15:50 +0300
Re: #define with semicolon Todd Carnes <toddcarnes@gmail.com> - 2011-07-22 21:46 +0000
Re: #define with semicolon Ian Collins <ian-news@hotmail.com> - 2011-07-23 09:54 +1200
Re: #define with semicolon Todd Carnes <toddcarnes@gmail.com> - 2011-07-22 22:21 +0000
Re: #define with semicolon Seebs <usenet-nospam@seebs.net> - 2011-07-23 00:12 +0000
Re: #define with semicolon Todd Carnes <toddcarnes@gmail.com> - 2011-07-23 00:37 +0000
Re: #define with semicolon Willem <willem@toad.stack.nl> - 2011-07-23 09:55 +0000
Re: #define with semicolon Robert Miles <milesrf@Usenet-News.net> - 2011-08-11 00:04 -0500
Re: #define with semicolon Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-07-22 15:54 -0600
Re: #define with semicolon Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-23 01:14 +0300
Re: #define with semicolon Todd Carnes <toddcarnes@gmail.com> - 2011-07-22 22:28 +0000
Re: #define with semicolon Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-23 02:52 +0300
Re: #define with semicolon Todd Carnes <toddcarnes@gmail.com> - 2011-07-23 00:14 +0000
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-22 16:52 -0700
Re: #define with semicolon Todd Carnes <toddcarnes@gmail.com> - 2011-07-23 00:07 +0000
Re: #define with semicolon Ben Pfaff <blp@cs.stanford.edu> - 2011-07-13 13:04 -0700
Re: #define with semicolon Barry Schwarz <schwarzb@dqel.com> - 2011-07-13 17:11 -0700
Re: #define with semicolon Walter Banks <walter@bytecraft.com> - 2011-07-14 08:11 -0400
Re: #define with semicolon pete <pfiland@mindspring.com> - 2011-07-14 08:24 -0400
Re: #define with semicolon "io_x" <a@b.c.invalid> - 2011-07-14 17:34 +0200
Re: #define with semicolon cc <scatnubbs@hotmail.com> - 2011-07-15 04:12 -0700
Re: #define with semicolon Anders Wegge Keller <wegge@wegge.dk> - 2011-07-15 14:49 +0200
Re: #define with semicolon Snit <usenet@gallopinginsanity.com> - 2011-07-15 08:37 -0700
Re: #define with semicolon "cc" <scatnubs@hotmail.com> - 2011-07-19 11:03 -0700
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-15 09:23 -0700
Re: #define with semicolon cc <scatnubbs@hotmail.com> - 2011-07-15 10:37 -0700
Re: #define with semicolon Snit <usenet@gallopinginsanity.com> - 2011-07-15 13:07 -0700
Re: #define with semicolon Keith Thompson <kst-u@mib.org> - 2011-07-15 13:26 -0700
Re: #define with semicolon Snit <usenet@gallopinginsanity.com> - 2011-07-15 13:31 -0700
Re: #define with semicolon cc <scatnubbs@hotmail.com> - 2011-07-19 08:55 -0700
Re: #define with semicolon "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-07-19 14:12 -0700
Re: #define with semicolon "cc" <scatnubs@hotmail.com> - 2011-07-19 11:05 -0700
Re: #define with semicolon cc <scatnubbs@hotmail.com> - 2011-07-19 11:18 -0700
Re: #define with semicolon Snit <usenet@gallopinginsanity.com> - 2011-07-19 11:23 -0700
Re: #define with semicolon cc <scatnubbs@hotmail.com> - 2011-07-19 11:31 -0700
Re: #define with semicolon "cc" <scatnubs@hotmail.com> - 2011-07-19 11:05 -0700
Re: #define with semicolon Snit <usenet@gallopinginsanity.com> - 2011-07-15 10:51 -0700
Re: #define with semicolon "cc" <scatnubs@hotmail.com> - 2011-07-19 11:04 -0700
Re: #define with semicolon "J. J. Farrell" <jjf@bcs.org.uk> - 2011-07-20 00:53 +0100
Re: #define with semicolon Snit <usenet@gallopinginsanity.com> - 2011-07-19 16:57 -0700
Re: #define with semicolon gordonb.ethca@burditt.org (Gordon Burditt) - 2011-07-15 10:33 -0500
Re: #define with semicolon Michael Angelo Ravera <maravera@prodigy.net> - 2011-07-22 10:55 -0700
csiph-web