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

#define str[8]

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



Joined: 06 Jan 2013
Posts: 6

View user's profile Send private message

#define str[8]
PostPosted: Wed Jun 11, 2014 8:52 am     Reply with quote

hi
i wonder how can i make this line work
Code:


#define str[8] {"PIN_E5,PIN_J8,PIN_J11,PIN_J14,PIN_J0,PIN_J4,PIN_J7,PIN_E2"}


i want to put my pins in array define, there is any way like that?
thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Wed Jun 11, 2014 9:12 am     Reply with quote

An array will work, but a 'define', can't have a size like this.
Square brackets are not allowed in a define. The square brackets in the manual entry for this (on some manuals), are for the 'optional' part.
#define is a text macro substitution language, not a variable declaration. #define is also not a string.
Code:

int16 pins[8] = {PIN_E5,PIN_J8,PIN_J11,PIN_J14,PIN_J0,PIN_J4,PIN_J7,PIN_E2} ;


will work, and you can then use 'pins[0]' and pins[3] etc., as pin numbers.

or
Code:

#define pinlist PIN_E5,PIN_J8,PIN_J11,PIN_J14,PIN_J0,PIN_J4,PIN_J7,PIN_E2
int16 pins[8] = {pinlist} ;


However also remember that pin functions involving variables are much bulkier and slower than those using constants.
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