To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 19977
19976  |  19978
Subject: 
Re: Brick Constants in NQC/Bricx
Newsgroups: 
lugnet.robotics
Date: 
Thu, 9 Jan 2003 04:08:12 GMT
Viewed: 
2710 times
  
__SCOUT and __RCX behave as you guessed.  There are also defines for
__CM and __SPY for spybotics and cybermaster targets, respectively.
These constants should work for BricxCC, or any other NQC environment
since they are defined by the NQC compiler.

For those interested, the NQC API is completely defined in a file named
rcx2.nqh (which gets built into the compiler to make installation of NQC
a bit simpler).  You don't need the source release to see this file...if
you run "nqc -api", it will print the API file to stdout.

Dave Baum

In article <3E1C3F40.4010206@airmail.net>,
lego-robotics@crynwr.com (Steve Baker) wrote:

> Paulo Tesche wrote:
> > Are there predefined constants generated by Bricx or NQC that identifies
> > the
> > Brick (RCX, SCout ...) to wich the generated code is targeted for?
> 
> Yes - I don't know about Bricx - but the NQC example programs contain one
> that says:
> 
>      #ifdef __RCX
> 
> ...and (more significantly) the system file 'compiler/rcx2.nqh' contains
> 
>      #if __RCX==2
> 
>      #if defined(__SCOUT)
> 
> ...and a bunch of other defines starting with two underscores.
> 
> The manual says that the compiler #include's 'rcx2.nqh' into your program
> automatically - which strongly suggests that these tokens are also available
> in your NQC programs.
> 
> So, I'm *guessing* that:
> 
>     1) The symbol __RCX is defined if you are building for an RCX - and it's
>        set to either 1 or 2 depending on what you used in the '-T' command
>        line
>        option.
> 
>     2) The symbol __SCOUT is defined if you are building for a SCOUT.
> 
> If all else fails, you could always run NQC like this:
> 
>     nqc -TScout -DTHIS_IS_A_SCOUT=1 my_program.nqc
>     nqc -TRCX2  -DTHIS_IS_AN_RCX=1  my_program.nqc
> 
> ....and then write:
> 
>     #ifdef THIS_IS_A_SCOUT
>        something
>     #endif
> 
>     #ifdef THIS_IS_AN_RCX
>        something_else
>     #endif
> 
> ...I've certainly used the '-D' command line option *many* times so I
> know it works for sure.
> 
> > It would be really usefull to write "multi-Brick" code in a single source
> > trough the use of #ifdef.
> 
> Yes - it's an obvious necessity and that's why I'm fairly sure NQC does
> it just as you'd expect.
> ---------------------------- Steve Baker -------------------------
> HomeEmail: <sjbaker1@airmail.net>    WorkEmail: <sjbaker@link.com>
> HomePage : http://www.sjbaker.org
> Projects : http://plib.sf.net    http://tuxaqfh.sf.net
>             http://tuxkart.sf.net http://prettypoly.sf.net
> 
> 



Message is in Reply To:
  Re: Brick Constants in NQC/Bricx
 
(...) Yes - I don't know about Bricx - but the NQC example programs contain one that says: #ifdef __RCX ...and (more significantly) the system file 'compiler/rcx2.nqh' contains #if __RCX==2 #if defined(__SCOUT) ...and a bunch of other defines (...) (24 years ago, 8-Jan-03, to lugnet.robotics)

5 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR