|
|
View previous topic :: View next topic |
Author |
Message |
ccsx3
Joined: 06 Jan 2013 Posts: 6
|
#define str[8] |
Posted: Wed Jun 11, 2014 8:52 am |
|
|
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: 19535
|
|
Posted: Wed Jun 11, 2014 9:12 am |
|
|
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. |
|
|
|
|
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
|