Subject:
|
Re: Having trouble with -D option
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Fri, 11 Feb 2000 03:23:02 GMT
|
Viewed:
|
1922 times
|
| |
| |
You found a bug - NQC is actually defining D to be the tokens =1, which
then leads to a lot of confusion later on. Basically I bungled the
pointer math.
I fixed the source so the next release (2.1 final) should be fine. I'll
probably release 2.1 in the next week or so.
I don't think there's much of a work-around, but if you need a quick
fix, download the source and change the DefineMacro() function in
nqc.cpp. The relevant change is to make sure the call to
Compiler::Get()->Define() uses 'body+1' rather than 'body'. Another
nice fix is to actually delete name, otherwise there's a memory leak.
Here's what the function should look like:
void DefineMacro(const char *text)
{
const char *body;
body = strchr(text, '=');
if (body)
{
// create a copy of the symbol name
int length = body - text;
char *name = new char[length+1];
memcpy(name, text, (size_t)length);
name[length] = 0;
Compiler::Get()->Define(name, body+1);
delete [] name;
}
else
{
Compiler::Get()->Define(text);
}
}
Dave
p.s. I'm glad you like the book.
In article <FpqLqs.35F@lugnet.com>, "Mark Haye" <haye@us.ibm.com>
wrote:
> If I compile this program (named d.nqc):
> /* nqc program */
> #if (D == 1)
> task main() {}
> #endif
>
> with the command:
> nqc -DD=1 d.nqc
>
> I get the following error:
> # Error: syntax error in expression
> File "d.nqc" ; line 2
> # #if (D == 1)
> # ^
> #----------------------------------------------------------
> # 1 error during compilation
>
> But change the program to this:
> /* nqc program */
> #define D 1
> #if (D == 1)
> task main() {}
> #endif
>
> and it works fine ... what am I missing?
>
> I'm using "nqc version 2.0.1 (built Oct 5 1999, 16:51:16)"
> from the CD that came with the book. Nice book, BTW.
--
reply to: dbaum at enteract dot com
|
|
Message has 3 Replies: | | Re: Having trouble with -D option
|
| Thanks for the quick response. "It's fixed in the next release, which is due in a week or so" qualifies for excellent support, IMHO. :) My workaround is a REXX exec rewritting a small header file on the fly before each compile. -- Mark Haye, haye (...) (25 years ago, 12-Feb-00, to lugnet.robotics.rcx.nqc)
| | | Re: Having trouble with -D option
|
| One other thing ... when I first made a simple program to demonstrate the problem, I used a lowercase d for my symbol and got this error: # Error: parse error File "rcx.nqh" ; line 118 # void SetDirection(const int o, const int d) { asm { 0xe1, (o) (...) (25 years ago, 12-Feb-00, to lugnet.robotics.rcx.nqc)
| | | Re: Having trouble with -D option
|
| It works fine in 2.1, as promised. Thanks Dave! -- Mark Haye, haye (at) us (dot) ibm (dot) com IBM TSM Server Development, Tucson, AZ Dave Baum <dbaum@spambgoneenteract.com> wrote in message news:dbaum-1DBD80.21...net.com... (...) ... (25 years ago, 24-Feb-00, to lugnet.robotics.rcx.nqc)
|
Message is in Reply To:
| | Having trouble with -D option
|
| If I compile this program (named d.nqc): /* nqc program */ #if (D == 1) task main() {} #endif with the command: nqc -DD=1 d.nqc I get the following error: # Error: syntax error in expression File "d.nqc" ; line 2 # #if (D == 1) # ^ #---...--- # 1 (...) (25 years ago, 10-Feb-00, to lugnet.robotics.rcx.nqc)
|
7 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
|
|
|
|