Home/Support/Support Forum/protected and typedef
New and improved user forum site coming soon
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

protected and typedef

0 votes
is it possible to initialize protected typedef struct variable?
(Dynamic c 9.62)

for example

typedef struct{
short ID;
unsigned char CardSerialNmb[CardNumberNuberOfBytes];
unsigned long Credit;
long coef_c;
unsigned long inserted;
typedef struct {
Card Cards[MAX];
unsigned char outs[MAX];
unsigned char cFlag[MAX];
short IdOfCards[MAX];
unsigned long count_kwh_ltr[MAX];
unsigned long count_old_kwh_ltr[MAX];
unsigned long tmpCount[MAX];

protected Db d;

void main()

It is global variable, on restart data is erased...

Best regards,
asked Jul 11, 2016 in Rabbit by antesasa New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
Based on my reading of code in SYS.LIB, it would appear that the protected keyword only applies to built-in types (int, long, float, etc.).

In your situation, you will need to create your own method of ensuring consistency in that data structure. One method would be to keep two copies of it, with a single protected variable indicating which copy to make use of.

Updates go to the "offline" copy. When you've confirmed that all changes are complete, toggle your status variable to take the "offline" variable "online" and start copying it to the other variable (now "offline").
answered Jul 11, 2016 by TomCollins Veteran of the Digi Community (2,382 points)