Difference between revisions of "Preprocessor Defines"

From ROBOTC API Guide
Jump to: navigation, search
(Created page with "{| style="font-family:Verdana, Genega, sans-sarif; font-size:80%;color:gray;" width="100%" cellpadding="0%" cellspacing="0" border="0" |- | ''Main >> [[Preproce...")
 
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{| style="font-family:Verdana, Genega, sans-sarif; font-size:80%;color:gray;" width="100%" cellpadding="0%" cellspacing="0" border="0"
+
<yambe:breadcrumb self="Preprocessor Defines">General|General Programming</yambe:breadcrumb>
 +
<br />
 +
 
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
|-
 
|-
|  
+
|The ROBOTC Compiler supports several different preprocessor defines that contain information about the compile time environment. Recently added are defines that indicate which features are enabled in the IDE.
''[[Main_Page|Main]] >> [[Preprocessor Defines|Preprocessor Defines]]''
+
|-
+
|}
+
  
 +
The predefined symbols can be used in include files and user programs for conditionally compiling code based on features. The preprocessor defines include:
 +
  {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:center; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 1px; border-style: solid; border-color: #000;" cellpadding="5%"
 +
  ! style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|''Symbol Name''
 +
  ! style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Usage / Comments
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|ROBOTC
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Indicates that the ROBOTC compiler was used.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|_DEBUG, _RELEASE, _CUSTOM
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Compiler optimization selection.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|_TARGET
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Contains the type of debugger target (select either “Robot”, “Emulator” or “VirtWorld”).
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|NXT, TETRIX, VEX, VEX20, ARDUINO
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|The currently selected platform.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|firmwareVersion
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Contains the numerical firmware version; e.g. 852.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|IFI
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|When IFI platform is selected.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|TETRIX
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|When TETRIX features are active.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|FTC
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|When FTC features are active.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|Algebra
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|When robot algebra option is enabled.
 +
  |-
 +
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|MultiRobotSupport
 +
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|When multi-robot option is enabled.
 +
  |-
 +
  |}
  
  
----
+
ROBOTC also supports the standard C preprocessor symbols below:
 
+
  {| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:center; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 1px; border-style: solid; border-color: #000;" cellpadding="5%"
 
+
  ! style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|''Symbol Name''
The ROBOTC Compiler supports several different preprocessor defines that contain information about the compile time environment. Recently added are defines that indicate which features are enabled in the IDE.
+
  ! style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Usage / Comments
 
+
  |-
The predefined symbols can be used in include files ad user programs for conditionally compiling code based on features. The preprocessor defines include:
+
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|__FILE__
 
+
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Current filename.
== Connecting Two NXT Bricks ==
+
  |-
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
+
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|__LINE__
|-
+
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Current line number.
|1.  Use the NXT user interface to select Bluetooth commands.
+
  |-
|-
+
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|__DATE__
|[[File:Bluetooth_connect_1.gif‎]]
+
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Date “mmm dd yyyy” of the current compilation.
|-
+
  |-
|2.  The top left of the NXT LCD status display shows the Bluetooth status. The leftmost icon  is the BT symbol and indicates that BT is enabled on the NXT. The icon indicates that the NXT BT visibility is enabled -- if visibility is disabled, then the NXT will not respond to search commands from other BT devices. "ROBOTC2" is the friendly name for the NXT.
+
  | style="font-family: Courier New, Courier, monospace; text-align:left; color:#8b0000; border-style: solid; border-width: 0px 0px 0px 0px"|__TIME__
|-
+
  | style="text-align:left; border-style: solid; border-width: 0px 0px 0px 0px"|Time “hh:mm:ss” of the current compilation.
|[[File:Bluetooth_connect_1.2.gif‎]]
+
  |-
|-
+
  |}
|3.  Then select "Search" command and run the command.
+
|-
+
|[[File:Bluetooth_connect_2.gif‎]]
+
|-
+
|4.  Once search has been performed, you'll be presented with a menu of the NXTs that were found via Bluetooth. In this case, only a single item -- the device "ROBOTC1" was found.
+
|-
+
|[[File:Bluetooth_connect_4.gif‎]]
+
|-
+
|5.  Select the target device for the connection from the search results -- i.e. "ROBOTC1" -- and then select "Connect"
+
|-
+
|[[File:Bluetooth_connect_5.gif‎]]
+
|-
+
|6.  The NXT supports connections to up to three "slave" devices. You need to select the appropriate "slot" (1, 2, or 3) for the connection. Select an empty slot -- all three slots are empty in the following picture -- and hit the orange button.
+
|-
+
|[[File:Bluetooth_connect_6.gif‎]]
+
|-
+
|7.  The NXT screen will show "Connecting" as the connection is attempted. Depending on the settings on your NXT, you may be prompted for a password.
+
|-
+
|[[File:Bluetooth_connect_7.gif‎]]
+
|-
+
|8.  Once the connection is made, the status ICON will change to "<>". The ">" indicates that the NXT is connected to another BT device.
+
|-
+
|[[File:Bluetooth_connect_8.gif‎]]
+
|-
+
 
|}
 
|}

Latest revision as of 14:48, 20 June 2012

General Programming → Preprocessor Defines


The ROBOTC Compiler supports several different preprocessor defines that contain information about the compile time environment. Recently added are defines that indicate which features are enabled in the IDE.

The predefined symbols can be used in include files and user programs for conditionally compiling code based on features. The preprocessor defines include:

Symbol Name Usage / Comments
ROBOTC Indicates that the ROBOTC compiler was used.
_DEBUG, _RELEASE, _CUSTOM Compiler optimization selection.
_TARGET Contains the type of debugger target (select either “Robot”, “Emulator” or “VirtWorld”).
NXT, TETRIX, VEX, VEX20, ARDUINO The currently selected platform.
firmwareVersion Contains the numerical firmware version; e.g. 852.
IFI When IFI platform is selected.
TETRIX When TETRIX features are active.
FTC When FTC features are active.
Algebra When robot algebra option is enabled.
MultiRobotSupport When multi-robot option is enabled.


ROBOTC also supports the standard C preprocessor symbols below:

Symbol Name Usage / Comments
__FILE__ Current filename.
__LINE__ Current line number.
__DATE__ Date “mmm dd yyyy” of the current compilation.
__TIME__ Time “hh:mm:ss” of the current compilation.