Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #28925

Re: Macros

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.c
Subject Re: Macros
Date 2012-12-04 20:03 -0500
Organization A noiseless patient Spider
Message-ID <k9m6g7$mt2$1@dont-email.me> (permalink)
References <xAMus.600270$yH4.30685@fx03.am4> <5814fff9-1958-4e28-9708-ac8cc4ed760e@googlegroups.com> <k9g8c9$4sd$1@dont-email.me> <k9m2pm$vfu$2@blue-new.rahul.net> <50BE91DE.1060404@verizon.net>

Show all headers | View raw


On 12/4/2012 7:14 PM, James Kuyper wrote:
> On 12/04/2012 06:59 PM, Edward A. Falk wrote:
>> In article <k9g8c9$4sd$1@dont-email.me>,
>> James Kuyper  <jameskuyper@verizon.net> wrote:
>>>>
>>>> You are violating standards here.
>>>> You may not use language keywords as macro names.
>>>
>>> Citation, please?
>>
>> Hardly matters.  Unless you're entering the obfuscated C programming
>> contest, doing this is a double-plus ungood idea, standard or no standard.
>
> It don't like the idea of doing it, but I also don't like saying
> incorrect things about what does and does not violate the requirements
> of the standard. Using language keywords does not violate any
> requirements imposed by the C standard. [...]

     7.1.2p4: "[...] The program shall not have any macros with
names lexically identical to keywords currently defined prior to
the inclusion of the header or when any macro defined in the header
is expanded."

     So, yes: You *can* #define `if' or `void' or `case' et al., but
only in restricted circumstances:

	#define int wuzzat
	#include <stdio.h>  // BZZZT!

	#include <stdio.h>
	#define int wuzzat
	size_t whiffle = BUFSIZ;  // BZZZT!

	#include <setjmp.h>
	#define int wuzzat
	...
	switch(setjmp(buf)) {  // BZZZT!
	

	#include <math.h>
	#define int wuzzat
	...
	return sin(x);  // BZZZT!  (`(sin)(x)' would be OK)

     Here's what I know: Anyone who engaged in this sort of thing,
even in formally permissible contexts, might not be fired after
the code review.  He would, however, become a figure of fun and
an object of scorn, the butt of continuing jokes.  (Did I mention
"companion of owls?"  Probably best that I didn't.)

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Macros "BartC" <bc@freeuk.com> - 2012-12-02 17:53 +0000
  Re: Macros Öö Tiib <ootiib@hot.ee> - 2012-12-02 10:11 -0800
    Re: Macros James Kuyper <jameskuyper@verizon.net> - 2012-12-02 13:58 -0500
      Re: Macros Öö Tiib <ootiib@hot.ee> - 2012-12-02 13:37 -0800
      Re: Macros falk@rahul.net (Edward A. Falk) - 2012-12-04 23:59 +0000
        Re: Macros James Kuyper <jameskuyper@verizon.net> - 2012-12-04 19:14 -0500
          Re: Macros Heikki Kallasjoki <fis+usenet@zem.fi> - 2012-12-05 00:58 +0000
            Re: Macros James Kuyper <jameskuyper@verizon.net> - 2012-12-04 20:44 -0500
          Re: Macros Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-04 20:03 -0500
            Re: Macros James Kuyper <jameskuyper@verizon.net> - 2012-12-04 20:48 -0500
              Re: Macros Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-12-05 23:17 +0200
    Re: Macros "BartC" <bc@freeuk.com> - 2012-12-02 19:54 +0000
      Re: Macros Ian Collins <ian-news@hotmail.com> - 2012-12-03 09:14 +1300
        Re: Macros Greg Martin <greg@softsprocket.com> - 2012-12-02 12:38 -0800
          Re: Macros pete <pfiland@mindspring.com> - 2012-12-02 16:28 -0500
            Re: Macros Rui Maciel <rui.maciel@gmail.com> - 2012-12-02 22:59 +0000
        Re: Macros "BartC" <bc@freeuk.com> - 2012-12-02 21:11 +0000
      Re: Macros "BartC" <bc@freeuk.com> - 2012-12-02 22:55 +0000
        Re: Macros ImpalerCore <jadill33@gmail.com> - 2012-12-03 06:48 -0800
        Re: Macros Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-12-09 03:15 -0800
  Re: Macros Ian Collins <ian-news@hotmail.com> - 2012-12-03 07:19 +1300
  Re: Macros James Dow Allen <jdallen2000@yahoo.com> - 2012-12-02 10:29 -0800
  Re: Macros Richard Damon <news.x.richarddamon@xoxy.net> - 2012-12-02 15:52 -0500
  Re: Macros Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-12-02 22:56 -0700
  Re: Macros Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-12-02 22:56 -0700
    Re: Macros "BartC" <bc@freeuk.com> - 2012-12-03 12:20 +0000
      Re: Macros Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-03 17:01 +0000
  Re: Macros Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-12-02 22:57 -0700
  Re: Macros "Heinrich Wolf" <invalid@invalid.invalid> - 2012-12-03 09:48 +0100
    Re: Macros Öö Tiib <ootiib@hot.ee> - 2012-12-03 07:34 -0800

csiph-web