Hi everyone,
How can I break a long instruction line into two or three lines to improve readability of the program written in " C language ?
Best regards, Deepak
This is a standard 'C' question - nothing specifically to do with Keil nor the 8051!
'C' treats all whitespace sequences (including comments) as equivalent - so, anywhere that one space is permitted, you can put as many spaces, tabs, newlines and comments as you like!
Basically, whitespace can come anywhere between tokens;
See your 'C' textbook.
*nitpick*
The C compiler does treat all whitespace sequences as equivalent. The preprocessor, however, doesn't.
Multiline macros, for example, need the '\' character to signal the continuation after the line break.
if you need to break a C statement into many lines, I would hate to read your C.
I know that "real C" is the attempt to write the entire program in one statement, but IMHO it STINKS.
for example
for ( .. ; a,b,c,d ; ...) is difficult to read and almost impossible to comment in a sesible fashion
can be so much more readable (and compiles more compact) if written for ( ... ; a ; ....) { ... if (b) break; // comment ... if (c) break; // comment ... if (d) break; // comment ... }
Erik
"if you need to break a C statement into many lines, I would hate to read your C."
Not necessarily.
For example, an if statement is a single statement (possibly including an else clause) - but it is very common indeed to split it over many lines!
Another example: a function call is a single statement:
func( a, b, c );
but it can be quite helpful to split it over several lines:
func ( a, // document the 1st parameter b, /* document the 2nd parameter */ c // document the 3rd parameter );
Hi Everyone,
Thank you very much for the help provided and for the faq link. My issue was only the readability problem. We have a 80 column limit here! That was sorted by Mr. Andy Neil's first mail. Thank you all so much for helping me.
Multi Line macro was a new information for me. I never used macros!!
Thanks for the for(... a, b, ...) example by Mr. Erik.
absolutely 'reasonable' to split lines, that intention of my post was not to argue that point. However the most frequent reason for line splittiing is the so called "real C programmers" LOVE of cramming as much into one statement as possible, and THAT was what I really stated about.
"if you heard what I thought I said, we would communicate well" :)
getting accustomed to your frequency,
say on
when asked, a simple redirection to other chips,
say on, what goes ahead,
is that another 'ghost'? It does not sound like Dan
Y a you guessed it right, eric,
View all questions in Keil forum