public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, trivial@rustcorp.com.au
Subject: Re: More cleanups for swsusp
Date: Wed, 21 Jan 2004 00:25:15 +0100	[thread overview]
Message-ID: <20040120232515.GD1234@elf.ucw.cz> (raw)
In-Reply-To: <20040120151358.09608fc3.akpm@osdl.org>

Hi!

> > +	BUG_ON (sizeof(struct link) != PAGE_SIZE);
> 
> Looking at the code, this hardly seems worth checking.  But the compiler
> should just rub this code out anwyay, so whatever.
> 
> hmm, one could do:
> 
> #define compile_time_assert(expr)					\
> 	do {								\
> 		if (!(expr))						\
> 			compile_time_assert_failed();	/* undefined */	\
> 	} while (0)

Well, if you provide such macro, I'll be happy to use it ;-). It
should be something like 

compile_time_assert(expr, "message")

because with more of these are in the code, it would be nightmare to
find out which one is wrong.

Perhaps better name, too?

pavel@elonex:/tmp$ cat delme.c

#define COMPILE_ERR_ON(expr, message) \
        do { if (!(expr)) compile_time_assert_failed_##message(); } while (0)

void main(void)
{
        COMPILE_ERR_ON(0==8, cpu_broke_zeros_neck);
        COMPILE_ERR_ON(0==0, compiler_went_crazy);
}
pavel@elonex:/tmp$ gcc delme.c -o delme
delme.c: In function `main':
delme.c:6: warning: return type of `main' is not `int'
/tmp/ccAx2alr.o(.text+0x11): In function `main':
: undefined reference to `compile_time_assert_failed_cpu_broke_zeros_neck'
collect2: ld returned 1 exit status
pavel@elonex:/tmp$



								Pavel

-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

  reply	other threads:[~2004-01-20 23:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-20 22:52 More cleanups for swsusp Pavel Machek
2004-01-20 23:13 ` Andrew Morton
2004-01-20 23:25   ` Pavel Machek [this message]
2004-01-21  5:10   ` Rusty Russell
2004-01-22  0:17     ` Pavel Machek
2004-01-21  5:14 ` Rusty Russell
2004-01-21  5:30   ` Andrew Morton
2004-01-21 18:39     ` Matt Mackall
2004-01-22  2:03       ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040120232515.GD1234@elf.ucw.cz \
    --to=pavel@suse.cz \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox