View previous topic :: View next topic |
Author |
Message |
girlinpink Guest
|
#define |
Posted: Sun Jun 15, 2008 9:39 am |
|
|
#define modo datain[0]
#define param1 datain[1]
#define param2 datain[2]
#define resultado dataout[0]
hello everybody. i'm pretty new to ccs and the code above is part of my usb coding. here's my question, what does the [1] or [2] mean?
thanks in advance! |
|
|
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Sun Jun 15, 2008 10:06 am |
|
|
"datain" is an array. datain[0] is the first element of the array, datain[1] the second element, and datain[2] the third. _________________ David |
|
|
girlinpink Guest
|
|
Posted: Sun Jun 15, 2008 10:17 am |
|
|
#define mode datain[0]
#define data datain[1]
#define param1 datain[1]
#define param2 datain[2]
#define modeo dataout[0]
#define sdcard dataout[1]
#define conv dataout[1]
#define result dataout[1]
#define swst dataout[1]
this is another example which i grabbed from the internet. part of the usb coding also. as u can see, there's two datain[1]. i'm still very confused. |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Mon Jun 16, 2008 2:44 am |
|
|
Basically the person who wrote the code created the #defines to make programming easier.
A #define value will be replaced by the definition during compile.
From what I can see I assume the code where the defines are used have 2 arrays available, datain[] and dataout[].
The data in the datain array is organised so that the value at index 0 [0] is the mode and from [1] onwards is the data. Also the data at [1] and [2] are known as param1 and param2.
It is similar to dataout where the value at index 1 [1] can be either sdcard, conv, result or swst depending on the modeo vaule.
So as you see it is just there way of making it easier to read the code. |
|
|
|