Forum : 8051
Original Post
Post Information | Post |
---|---|
March 17, 2007 - 4:37pm
|
Hello, does Ride support structs? #include #include struct Fonema { char a[2]; }; void main() { Fonema letra; while(1) { if (P0 == 00000001) { strcpy(letra.a,"bla"); } } } Could anyone answer my question or help me? Thanks! ^^ PS: I'm coding it for the 80C51... |
Nvm, I found what was wrong.
I went in Options,Project,RC51,Source and marked ('struct/ union/ enum' optional).
Bye!
Hello,
in fact the standard ANSI C syntax does not allow the declaration of a structure the way you did it on your example. This is only allowed in C++ syntax. The standard C syntax is:
You could also define a new type 'Fonema' using typedef:
regards,
Lionel
Thanks, but how I said before, I solucioned the problem and it worked with the code of C++, I tested my program, so I will keep using in that way ^^'
Bye! :P
in fact the standard ANSI C syntax does not allow the declaration of a structure the way you did it on your example
then
Thanks, but how I said before, I solucioned the problem and it worked with the code of C++, I tested my program, so I will keep using in that way
Then what will you do the day Raisonance realize they allow something they should not allow?
Erik
Well, I think that they know what they are doing because there is a option on the Project Options that let you do what I did... Look:
And if they remove this I just change my structures to the C form, that's not hard to do ;D
And if they remove this I just change my structures to the C form, that's not hard to do
why not do it now?
Getting in the habit of using non-standard C can easily get you to where 'something' goes wrong for 'some' reason and THAT would be one hellacious debugging session.
No bad about Raisonance in this statement, please do not read it as such, but do you really think that the support for non-standard is the area where Raisonance spend the most verification time?
two wrongs do not make a right
Erik
Pass to the C form? How this should be? :O
Because you said above that the C structures that lionel used are not accepted in RIDE, am I right?
Bye!
I don't think that's what Erik wanted to say.
We all agree that the syntax I gave is correct in C. I add now that this syntax is always valid, even if the 'struct/enum optional' option is checked. It will always work. Checking the option is a way to write code in a way some people prefer, but it is not standard C. Standard C syntax will always be valid, whatever the options status.
IMHO, Erik (correct me if I am wrong) wanted to express that the standard C syntax is preferable because it will always work, and that we may, one day or another, remove this option. For now the option is here, feel free to use it.
regards
Lionel
Mmmmm, so what is the right way to use structures in standard C?
Ok, thanks :P
Bye!