View previous topic :: View next topic |
Author |
Message |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
Line wrap for clarity...?? |
Posted: Sun Nov 21, 2010 7:30 pm |
|
|
Hi All,
I haven't found this anywhere, so I thought I'd ask. Is there a character that the compiler understands to be a 'line wrap' character, or is there something like this that is part of standard 'C' syntax? I've got some conditional statements that are quite lengthy, and for clarity it would be nice to separate these lines of code into two physical lines. In VB6 and VB.net, the "_" (underscore) character does this. Is there anyway to do it with CCS C? If it matters, I use MPLAB as my IDE.
Thanks,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19551
|
|
Posted: Mon Nov 22, 2010 3:14 am |
|
|
and, just for 'completeness', 'yes', this is part of 'C', not specific to CCS.
Best Wishes |
|
|
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Mon Nov 22, 2010 4:08 am |
|
|
If you mean within the compiler, rather than when you output data, then yes just start a new line.
So if you wanted to flash an LED you could have:
Code: |
output_high(PIN_A0); delay_ms(500); output_low(PIN_A0); delay_ms(500);
|
or
Code: |
output_high(PIN_A0);
delay_ms(500);
output_low(PIN_A0);
delay_ms(500); |
or even
Code: |
output_high(
PIN_A0);
delay_ms(
500);
output_low(
PIN_A0);
delay_ms(
500); |
|
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Mon Nov 22, 2010 5:39 am |
|
|
In case you missed it in the link PCM programmer posted it is the \ char.
This is the standard escape char for C compilers and will escape (ignore) the end of line so it thinks the separate lines are in fact 1 very long line.
This only needs to be used where it matters and as shown some lines can be split without the need to use it:-
Code: |
if ((val > val2) &&
val3 == val4) &&
val5 > val6))
{
}
my_very_long_val_name = \
another_very_long_val_name;
|
But don't just use it for the sake of it as it could make your code unreadable! |
|
|
|