14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License (the "License").
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You may not use this file except in compliance with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * ASSERTION:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Test the typedef keyword with the different D data types. Declare different
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * data types and test some of them with values.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * SECTION: Type and Constant Definitions/Typedef
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma ident "%Z%%M% %I% %E% SMI"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma D option quiet
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef char new_char;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef short new_short;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int new_int;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef long new_long;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef long long new_long_long;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int8_t new_int8;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int16_t new_int16;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int32_t new_int32;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int64_t new_int64;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef intptr_t new_intptr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef uint8_t new_uint8;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef uint16_t new_uint16;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef uint32_t new_uint32;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef uint64_t new_uint64;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef uintptr_t new_uintptr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef float new_float;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef double new_double;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef long double new_long_double;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int * pointer;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char ch;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int in;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync long lg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} new_struct;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef union {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char ch;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int in;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync long lg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} new_union;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef enum {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RED,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync GREEN,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync BLUE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} new_enum;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_char c;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_short s;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_int i;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_long l;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_long_long ll;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_int8 i8;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_int16 i16;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_int32 i32;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_int64 i64;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_intptr iptr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_uint8 ui8;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_uint16 ui16;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_uint32 ui32;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_uint64 ui64;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_uintptr uiptr;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_float f;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_double d;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_long_double ld;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_struct ns;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_union nu;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnew_enum ne;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncpointer p;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncBEGIN
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ns.ch = 'c';
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ns.in = 4;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ns.lg = 4;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nu.ch = 'd';
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nu.in = 5;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync nu.lg = 5;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i = 10;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("Struct: %c, %d, %d\n", ns.ch, ns.in, ns.lg);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("Union: %c, %d, %d\n", nu.ch, nu.in, nu.lg);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit(0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}