This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi, I want to know if C2000 compiler supports unnamed fields. unnamed structs and unions can be used with -fms-extensions in C. The c2000 compiler manual says that Unnamed fields are supported, where as when I use the flag in code, the compiler is throwing an error that -fms-extension is not recognized.
Can someone please clarify this?
Thanks,
Bharath
https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Unnamed-Fields.html#Unnamed-Fields please see this link on more info on fms-extensions
I want to know if C2000 compiler supports unnamed fields
It does, by default. No options are necessary.
The extensions of unnamed fields, which GCC documentation says are available under the flags -fms-extensions or -fplan9-extensions, are not supported. This is because the C28x compiler is not based on GCC, and does not support those options.
Thanks and regards,
-George
Hi George,
So, we have code that utilize unnamed fields, specifically unnamed structs. The compiler is giving an error when we try to use these structs.
To give an example:
If I try to access members of s1 from an instance of s2,like, s2->current compiler gives and error.
We have used these unnamed fields with fms-extensions flag. I have relaxed-ansi flag in setting as per c2000 compiler manual as well.
We have used these unnamed fields with fms-extensions flag
I meant to say that this type of code works with fms-extensions flag on other gcc based mcu.
This variant of unnamed fields you use, where struct s1 is not completely specified inside of struct s2, is not supported by the C28x compiler.
Thanks and regards,
-George
Hi George,
Thanks for the quick reply. The reason I am asking about this is that our internally architected code uses unnamed fields a lot to create a modular design.
Could you give me an example of how you would create an unnamed struct inside a struct that satisfies the C2000 compiler?? Maybe we can adapt our internal code to support this variation for reusability. Any suggestion here will be much appreciated.
Thanks,
Bharath
give me an example of how you would create an unnamed struct inside a struct that satisfies the C2000 compiler
struct s2 { struct { uint16_t init; uint16_t current; }; uint16_t data1; uint16_t data2; };
The unnamed struct must be completely specified inside the named struct that contains it.
Thanks and regards,
-George