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 40 typedef char new_char; 41 typedef short new_short; 42 typedef int new_int; 43 typedef long new_long; 44 typedef long long new_long_long; 45 typedef int8_t new_int8; 46 typedef int16_t new_int16; 47 typedef int32_t new_int32; 48 typedef int64_t new_int64; 49 typedef intptr_t new_intptr; 50 typedef uint8_t new_uint8; 51 typedef uint16_t new_uint16; 52 typedef uint32_t new_uint32; 53 typedef uint64_t new_uint64; 54 typedef uintptr_t new_uintptr; 55 typedef float new_float; 56 typedef double new_double; 57 typedef long double new_long_double; 58 59 typedef int * pointer; 60 61 typedef struct { 62 char ch; 63 int in; 64 long lg; 65 } new_struct; 66 67 typedef union { 68 char ch; 69 int in; 70 long lg; 71 } new_union; 72 73 typedef enum { 74 RED, 75 GREEN, 76 BLUE 77 } new_enum; 78 79 new_char c; 80 new_short s; 81 new_int i; 82 new_long l; 83 new_long_long ll; 84 new_int8 i8; 85 new_int16 i16; 86 new_int32 i32; 87 new_int64 i64; 88 new_intptr iptr; 89 new_uint8 ui8; 90 new_uint16 ui16; 91 new_uint32 ui32; 92 new_uint64 ui64; 93 new_uintptr uiptr; 94 new_float f; 95 new_double d; 96 new_long_double ld; 97 new_struct ns; 98 new_union nu; 99 new_enum ne; 100 101 pointer p; 102 103 BEGIN 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