C# 클래스 ABT.Initr

1. Scalar: an expression, optionally enclosed in braces. int a = 1; // valid int a = { 1 }; // valid int a[] = { { 1 }, 2 }; // valid int a = {{ 1 }}; // warning in gcc, a == 1; error in MSVC int a = { { 1 }, 2 }; // warning in gcc, a == 1; error in MSVC int a = { 1, 2 }; // warning in gcc, a == 1; error in MSVC I'm following MSVC: you either put an expression, or add a single layer of brace. 2. Union: union A { int a; int b; }; union A u = { 1 }; // always initialize the first member, i.e. a, not b. union A u = {{ 1 }}; // valid union A u = another_union; // valid 3. Struct: struct A { int a; int b; }; struct A = another_struct; // valid struct A = { another_struct }; // error, once you put a brace, the compiler assumes you want to initialize members. From 2 and 3, once seen union or struct, either read expression or brace. 4. Array of characters: char a[] = { 'a', 'b' }; // valid char a[] = "abc"; // becomes char a[4]: include '\0' char a[3] = "abc"; // valid, ignore '\0' char a[2] = "abc"; // warning in gcc; error in MSVC If the aggregate contains members that are aggregates or unions, or if the first member of a union is an aggregate or union, the rules apply recursively to the subaggregates or contained unions. If the initializer of a subaggregate or contained union begins with a left brace, the initializers enclosed by that brace and its matching right brace initialize the members of the subaggregate or the first member of the contained union. Otherwise, only enough initializers from the list are taken to account for the members of the first subaggregate or the first member of the contained union; any remaining initializers are left to initialize the next member of the aggregate of which the current subaggregate or contained union is a part.
파일 보기 프로젝트 열기: phisiart/C-Compiler 1 사용 예제들

공개 메소드들

메소드 설명
ConformType ( ExprType type ) : Initr
ConformType ( MemberIterator iter ) : Initr
Iterate ( ExprType type, Expr>.Action action ) : void
Iterate ( MemberIterator iter, Expr>.Action action ) : void

메소드 상세

ConformType() 공개 메소드

public ConformType ( ExprType type ) : Initr
type ExprType
리턴 Initr

ConformType() 공개 추상적인 메소드

public abstract ConformType ( MemberIterator iter ) : Initr
iter MemberIterator
리턴 Initr

Iterate() 공개 메소드

public Iterate ( ExprType type, Expr>.Action action ) : void
type ExprType
action Expr>.Action
리턴 void

Iterate() 공개 추상적인 메소드

public abstract Iterate ( MemberIterator iter, Expr>.Action action ) : void
iter MemberIterator
action Expr>.Action
리턴 void