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