We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I am trying to initialize a struct, but I get the following error:
Error #29: Expected an expression
typedef struct { atp V1; atp V2; atp V3; atp V4; } tosh_at; tosh_at tosh_options ={ .V1 = 12, .V3 = 5, };
Can someone please help me. Thanks in advance.
First try the most basic google search about how to initialize structures.
I already did and just found a solution to initialize all variables
tosh_at tosh_options ={12,10,5,2};
But I want to initialize just two of them.
This is C99 syntax. IIRC, the default compiler mode is C90. Try adding --c99 to the compiler command line options.
www.keil.com/.../armccref_cihihhgf.htm
"Try adding --c99 to the compiler command line options"
In the GUI, you can use the Misc Controls box on the Compiler options tab:
http://www.keil.com/support/man/docs/uv4/uv4_dg_adscc.htm
--c99 works! Thanks for the help =)
It is always important to have a running knowledge about the C language standard, since not all (especially embedded) compilers complies with the most recent standard. It's just a too small market to invest all the time for larger compiler rewrites.
That is also one of the reasons why many embedded compilers defaults to older language standards even when a newer standard is supported.
I wonder how long it will take for C11 to become widespread... It does promise some nice features.