Studio:Applying pragmas up and down type chains

From STRIDE Wiki
Jump to: navigation, search

When a type T has a pragma applied to it, it also applies to any types that are defined in terms of T.

In the following SCL, Example 1 demonstrates when the scl_union pragma has no effect on pS, S1, or pS1. This is by design. In order for the pragma to apply, it must be structured as shown in Example 2.

Example 1

typedef struct {
  enum {A,B}  discrim;
  union 
  {
    int x; 
    float f; 
  } u; 
} S, *pS, S1, *pS1; 
#pragma scl_union(S, u, discrim);

Example 2

typedef struct {
  enum {A,B}  discrim;
  union
  {
     int x; 
     float f; 
  } u; 
} S; 
typedef S* pS;  
#pragma scl_union(S, u, discrim);