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 D option quiet 37 38 typedef char new_char; 39 typedef short new_short; 40 typedef int new_int; 41 typedef long new_long; 42 typedef long long new_long_long; 43 typedef int8_t new_int8; 44 typedef int16_t new_int16; 45 typedef int32_t new_int32; 46 typedef int64_t new_int64; 47 typedef intptr_t new_intptr; 48 typedef uint8_t new_uint8; 49 typedef uint16_t new_uint16; 50 typedef uint32_t new_uint32; 51 typedef uint64_t new_uint64; 52 typedef uintptr_t new_uintptr; 53 typedef float new_float; 54 typedef double new_double; 55 typedef long double new_long_double; 56 57 typedef int * pointer; 58 59 typedef struct { 60 char ch; 61 int in; 62 long lg; 63 } new_struct; 64 65 typedef union { 66 char ch; 67 int in; 68 long lg; 69 } new_union; 70 71 typedef enum { 72 RED, 73 GREEN, 74 BLUE 75 } new_enum; 76 77 new_char c; 78 new_short s; 79 new_int i; 80 new_long l; 81 new_long_long ll; 82 new_int8 i8; 83 new_int16 i16; 84 new_int32 i32; 85 new_int64 i64; 86 new_intptr iptr; 87 new_uint8 ui8; 88 new_uint16 ui16; 89 new_uint32 ui32; 90 new_uint64 ui64; 91 new_uintptr uiptr; 92 new_float f; 93 new_double d; 94 new_long_double ld; 95 new_struct ns; 96 new_union nu; 97 new_enum ne; 98 99 pointer p; 100 101 BEGIN 102 { 103 ns.ch = 'c'; 104 ns.in = 4; 105 ns.lg = 4; 106 107 nu.ch = 'd'; 108 nu.in = 5; 109 nu.lg = 5; 110 111 i = 10; 112 113 printf("Struct: %c, %d, %d\n", ns.ch, ns.in, ns.lg); 114 printf("Union: %c, %d, %d\n", nu.ch, nu.in, nu.lg); 115 exit(0); 116 } 117