Previous Next Contents Index Doc Set Home


-Xs Differences for Sun C
and ANSI C

C


This appendix describes the differences in compiler behavior when using the
-Xs option. The -Xs option tries to emulate Sun C 1.0, and Sun C 1.1 (K&R style), but in some cases it cannot emulate the previous behavior.

Table  C-1 -Xs Behavior  
Data Type
Sun C (K&R)
Sun ANSI C (4.0)

Aggregate initialization:

struct {

int a[3];
int b;

} w[] = { {1} , 2};

sizeof (w) = 16
w[0].a = 1, 0, 0
w[0].b =2

sizeof(w) = 32
w[0].a = 1, 0, 0
w[0].b = 0
w[1].a = 2, 0, 0
w[1].b = 0

Incomplete struct, union, enum declaration

struct fq {
int i;
struct unknown;
};

Does not allow incomplete struct, union, and enum declaration.

Switch expression integral type

Allows non-integral type.

Does not allow non-integral type.

Order of precedence

Allows:

if (rcount > count += index)

Does not allow:

if (rcount > count += index)

unsigned, short, and
long typedef declarations

Allows:

typedef short small
unsigned small;

Does not allow (all modes).

struct or union tag mismatch in nested struct or union
declarations

Allows tag mismatch:

struct x {
int i;
} s1;

/* K&R treats as a struct */
{
union x s2;
}

Does not allow tag mismatch in nested struct or union declaration.

Incomplete struct or union type

Ignores an incomplete type declaration.

struct x {
int i;
} s1;


main()
{
struct x;
struct y {
struct x f1

/* in K&R, f1 refers */
/* to outer struct */
} s2;
struct x {
int i;

};

}

Casts as lvalues

Allows:

(char *) ip = &foo;

Does not allow casts as lvalues (all modes).


Previous Next Contents Index Doc Set Home