tst.TypedefDataAssign.d revision 285830
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27/* 28 * ASSERTION: 29 * Test the typedef keyword with the different D data types. Declare different 30 * data types and test some of them with values. 31 * 32 * SECTION: Type and Constant Definitions/Typedef 33 * 34 */ 35 36#pragma ident "%Z%%M% %I% %E% SMI" 37 38#pragma D option quiet 39 40typedef char new_char; 41typedef short new_short; 42typedef int new_int; 43typedef long new_long; 44typedef long long new_long_long; 45typedef int8_t new_int8; 46typedef int16_t new_int16; 47typedef int32_t new_int32; 48typedef int64_t new_int64; 49typedef intptr_t new_intptr; 50typedef uint8_t new_uint8; 51typedef uint16_t new_uint16; 52typedef uint32_t new_uint32; 53typedef uint64_t new_uint64; 54typedef uintptr_t new_uintptr; 55typedef float new_float; 56typedef double new_double; 57typedef long double new_long_double; 58 59typedef int * pointer; 60 61typedef struct { 62 char ch; 63 int in; 64 long lg; 65} new_struct; 66 67typedef union { 68 char ch; 69 int in; 70 long lg; 71} new_union; 72 73typedef enum { 74 RED, 75 GREEN, 76 BLUE 77} new_enum; 78 79new_char c; 80new_short s; 81new_int i; 82new_long l; 83new_long_long ll; 84new_int8 i8; 85new_int16 i16; 86new_int32 i32; 87new_int64 i64; 88new_intptr iptr; 89new_uint8 ui8; 90new_uint16 ui16; 91new_uint32 ui32; 92new_uint64 ui64; 93new_uintptr uiptr; 94new_float f; 95new_double d; 96new_long_double ld; 97new_struct ns; 98new_union nu; 99new_enum ne; 100 101pointer p; 102 103BEGIN 104{ 105 ns.ch = 'c'; 106 ns.in = 4; 107 ns.lg = 4; 108 109 nu.ch = 'd'; 110 nu.in = 5; 111 nu.lg = 5; 112 113 i = 10; 114 115 printf("Struct: %c, %d, %d\n", ns.ch, ns.in, ns.lg); 116 printf("Union: %c, %d, %d\n", nu.ch, nu.in, nu.lg); 117 exit(0); 118} 119