CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Line wrap for clarity...??

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

Line wrap for clarity...??
PostPosted: Sun Nov 21, 2010 7:30 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 21, 2010 7:42 pm     Reply with quote

This post has an example:
http://www.ccsinfo.com/forum/viewtopic.php?t=40263&start=1
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Mon Nov 22, 2010 3:14 am     Reply with quote

and, just for 'completeness', 'yes', this is part of 'C', not specific to CCS.

Best Wishes
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Mon Nov 22, 2010 4:08 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 22, 2010 5:39 am     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group