Strange compiler error/warning flagging [SOLVED]
Hi,
If your code is as you show, the error is normal: the last line ( CliCmd.num = 0;
) is an assignment; it can’t be placed at global file level, but must be inside some function.
If you want to statically initialize CliCmd by just setting num to 0, you must replace your last two lines by cli_cmd CliCmd = { .num = 0 };
Be careful not to forget the dot before num; if you need to also initialize other fields separate them by commas inside the braces (the order does not mind).
Note however that, if you want to initialize all fields to zero, you may as well do nothing, as the C compiler will initailize all non-initialized variables and fields to 0.
Bernard (Ac6)