|
|
Subscribe / Log in / New account

detecting integer constant expressions in macros

From:  "Uecker, Martin" <Martin.Uecker-AT-med.uni-goettingen.de>
To:  "torvalds-AT-linux-foundation.org" <torvalds-AT-linux-foundation.org>
Subject:  detecting integer constant expressions in macros
Date:  Tue, 20 Mar 2018 22:13:35 +0000
Message-ID:  <1521584015.31174.3.camel@med.uni-goettingen.de>
Cc:  "linux-kernel-AT-vger.kernel.org" <linux-kernel-AT-vger.kernel.org>


Hi Linus,

here is an idea:

a test for integer constant expressions which returns an
integer constant expression itself which should be suitable
for passing to __builtin_choose_expr might be:

#define ICE_P(x) (sizeof(int) == sizeof(*(1 ? ((void*)((x) * 0l)) :
(int*)1)))

This also does not evaluate x itself on gcc although this is
not guaranteed by the standard. (And I haven't tried any older
gcc.)

Best,
Martin


to post comments


Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds