🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

5 total messages Started by Stan Novinsky Fri, 29 Mar 1996 12:23
Nested MACROS ??
#4966
Author: Stan Novinsky
Date: Fri, 29 Mar 1996 12:23
9 lines
729 bytes
I am using a nested MACRO.  The problem is that only the 
inner part is execur

Given the following MACRO definitions and code,

 #define CUBE(X)   ((x * x) * x)
 #define ABS(X)    ((x < 0)   ? -(x) : (x))

 #define NEST(X)        (ABS(CUBE(X)))
Re: Nested MACROS ??
#4969
Author: Eric J. Korpela
Date: Fri, 29 Mar 1996 19:38
20 lines
1036 bytes
In article <4jgkno$mrr@aplinfo.jhuapl.edu>,
Stan Novinsky  <stan_novinsky@jhuapl.edu> wrote:
>I am using a nested MACRO.  The problem is that only the 
>inner part is execur
>
>Given the following MACRO definitions and code,
>
> #define CUBE(X)   ((x * x) * x)
> #define ABS(X)    ((x < 0)   ? -(x) : (x))
>
> #define NEST(X)        (ABS(CUBE(X)))

The C preprocessor is case sensitive.  Look carefully at your code.

Eric
-- 
Eric Korpela                        |  An object at rest can never be
korpela@ssl.berkeley.edu            |  stopped.
<a href="http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpela/w">
Click here for more info.</a>
Re: Nested MACROS ??
#4975
Author: Stan Novinsky
Date: Mon, 01 Apr 1996 17:27
16 lines
899 bytes
Yes, I ses the problem.  I took care of it 
by changing to lower case x, however, I still 
don't understand why the call to the MACROS on 
an individual basis works...

EX :

  X = 4;

  cube_ans = CUBE(X);

This returns the correct value (64) when I run the program...

Thanks for all the responses ...

Stan
Re: Nested MACROS ??
#4978
Author: James M. Curran
Date: Tue, 02 Apr 1996 20:58
25 lines
1265 bytes
In <<4jp3mi$bqc@aplinfo.jhuapl.edu>>, 
Stan Novinsky <stan_novinsky@jhuapl.edu> wrote:

>Yes, I ses the problem.  I took care of it 
>by changing to lower case x, however, I still 
>don't understand why the call to the MACROS on 
>an individual basis works...
>EX :
>  X = 4;
>  cube_ans = CUBE(X);

>This returns the correct value (64) when I run the program...
>Thanks for all the responses ...

	No it doesn't -- it won't even compile.  However, if you change the
first line to "int x = 4;"  (note lower-case this time) then it will.
CUBE() as it was written in your original post will cube the value
stored in the varaible named (lowercase) "x".  The arguement to CUBE
is ignored (since it doesn't appear in the macro definition)




       Truth,
       James
Re: Nested MACROS ??
#4980
Author: Christopher R Volpe
Date: Tue, 02 Apr 1996 21:32
20 lines
1154 bytes
Stan Novinsky wrote:
> 
> I am using a nested MACRO.  The problem is that only the
> inner part is execur
> 
> Given the following MACRO definitions and code,
> 
>  #define CUBE(X)   ((x * x) * x)
>  #define ABS(X)    ((x < 0)   ? -(x) : (x))
> 
>  #define NEST(X)        (ABS(CUBE(X)))

It would probably help if you didn't mix'n'match capital X's and
lowercase x's in your macro "prototype" and replacement list.

--

Chris Volpe				Phone: (518) 387-7766 (Dial Comm 8*833
GE Corporate R&D			Fax:   (518) 387-6560
PO Box 8, Schenectady, NY 12301		Email: volpecr@crd.ge.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads