I just started using kile c51 compiler with µVision. My problem is only a stylistic issue. While initializing my controler: <dir>
unsigned char dummy1 = 0xFF; /* call openADC0 */ openADC0( dummy1 ); unsigned char dummy2 = 0xFF; /* call openADC0 */ openUART0( dummy2 );
Thanks, I know but is there realy no compiler instruction for keil? No, since turning a C compiler into a somewhat-but-not-quite C++ compiler does not make much sense. Being able to declare variables is a feature of C++. If you are using a C compiler, then write C code, not some C/C++ hybrid code.
"Being able to declare variables is a feature of C++." Errr... I think you missed a bit there?! Something like: "Being able to define variables in the middle of a block is a feature of C++." Both declaring and defining variables are, of course, entirely possible in 'C'! ;-)
From the snippet given, I don't see any point to having the variable at all, instead of passing the constant 0xFF directly to the function. But perhaps there's more to the actual code. ANSI C does permit declaration of local blocks, inside of which you can declare variables. This is an often overlooked feature of C. It's sometimes handy to constrain the scope of temporary variables. The following is legal ANSI C.
{ unsigned int data dummy1 = 0xFF; func1 (dummy1); } { unsigned int data dummy2 = 0xFF; func2 (dummy2); }
Thank you all very much for your know how and for Your effort. I learned a lot and I hope I will be learning a lot more here as well as in other threads. Regards J.
Note that what you have learned here is standard ANSI 'C' - nothing specifcally to do with Keil nor the 8051!