From owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org  Thu Dec 11 01:39:39 2014
Return-Path: <owner-sc22wg14+sc22wg14-domo2=www.open-std.org@open-std.org>
X-Original-To: sc22wg14-domo2
Delivered-To: sc22wg14-domo2@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id DBE6035852E; Thu, 11 Dec 2014 01:39:38 +0100 (CET)
Delivered-To: sc22wg14@open-std.org
X-Greylist: delayed 400 seconds by postgrey-1.34 at www5.open-std.org; Thu, 11 Dec 2014 01:39:38 CET
Received: from mail1313.opentransfer.com (mail1313.opentransfer.com [76.162.254.106])
	by www.open-std.org (Postfix) with ESMTP id 278F1356D10
	for <sc22wg14@open-std.org>; Thu, 11 Dec 2014 01:39:35 +0100 (CET)
Received: (qmail 6704 invoked by uid 399); 11 Dec 2014 00:32:53 -0000
Received: from unknown (HELO W500) (pbs:tydeman@tybor.com@108.233.167.175)
  by mail1313.opentransfer.com with ESMTPM; 11 Dec 2014 00:32:53 -0000
X-Originating-IP: 108.233.167.175
Message-ID: <100.c8610d0034e68854.003@tybor.com>
From: "Fred J. Tydeman" <tydeman@tybor.com>
To: "ISO C" <sc22wg14@open-std.org>
Date: Wed, 10 Dec 2014 16:32:52 -0800 (PST)
User-Agent: PMMail/3.11 (os/2; U; Warp 4.5; en-US; i386; ver 3.11.30.1767)
X-Mailer: PMMail 3.11.30.1767 for OS/2 Warp 4.5
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Subject: _Generic and bit-fields
Sender: owner-sc22wg14@open-std.org
Precedence: bulk

/*
 * What should print=3F
 * If i is 0, what can I use to match bit-field in the =5FGeneric=3F
 * How can =5FGeneric be used to match bit-field types=3F
 */

#include <stdio.h>

int main(void){

  struct {
    unsigned int bf: 4;         /* bit-field */
  } st;
  int i;

  st.bf =3D 0;
  i =3D =5FGeneric(st.bf,
               signed char: 5,
               unsigned char: 6,
               signed short: 1,
               unsigned short: 2,
               unsigned int: 3,
               signed int: 4,
               default: 0);

  (void)printf("i=3D%i\n", i);
  (void)printf("bf=3D%i\n", (int)st.bf);

  return 0;
}


---
Fred J. Tydeman        Tydeman Consulting
tydeman@tybor.com      Testing, numerics, programming
+1 (775) 287-5904      Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.
