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 / 19952
19951  |  19953
Subject: 
Re: Brick Constants in NQC/Bricx
Newsgroups: 
lugnet.robotics
Date: 
Wed, 8 Jan 2003 15:09:52 GMT
Original-From: 
Steve Baker <SJBAKER1@AIRMAILstopspam.NET>
Viewed: 
598 times
  
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 has 1 Reply:
  Re: Brick Constants in NQC/Bricx
 
__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. (...) (21 years ago, 9-Jan-03, to lugnet.robotics)

Message is in Reply To:
  Brick Constants in NQC/Bricx
 
Are there predefined constants generated by Bricx or NQC that identifies the Brick (RCX, SCout ...) to wich the generated code is targeted for? It would be really usefull to write "multi-Brick" code in a single source trough the use of #ifdef. Paulo (...) (21 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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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