#pragma anon_struct

From RAD Studio
Jump to: navigation, search

Go Up to Pragma Directives Overview Index

Syntax (See Pseudo-grammar)

#pragma anon_struct on
#pragma anon_struct off

Description

The anon_struct directive allows you to compile anonymous structures embedded in classes.

Example

 #pragma anon_struct on

 struct S {
    int i;
    struct {  // Embedded anonymous struct
       int   j ;
       float x ;
    };
    class {  // Embedded anonymous class
    public:
       long double ld;
    };
    S() { i = 1; j = 2; x = 3.3; ld = 12345.5;}
 };
 #pragma anon_struct off

 void main()
 {
    S mystruct;
    mystruct.x = 1.2;  // Assign to embedded data.
 }