Justin Richards wrote:
> I find these processor directives difficult because I cant tell what
> the processor thinks their values are. I managed to work out how to
> pass a structure by reference because the debugger gives me feedback.
>
> Is there a directive that I can use to echo the value of the various
> defines or better yet is there documentation that describes these
> directive. What confuses me even more is that some people put these
> in a section of their code called Macros.
In C, everything that's defined with a #define directive is called a
"macro". It may be a simple value (often used for defining constants
without spending RAM on them) or a complex construct with arguments and
multiple levels of substitution. The C preprocessor is not always
intuitive, so when you get to more complex constructs, don't be
surprised about surprises :)
AFAIK there's no way to directly display preprocessor values. Your
compiler may have a non-standard way, though, so check its manual.
If you suspect what the value is, you can use an #if variable ==
suspected_value/#error construct to confirm your suspicion. (This is
similar to what you did, so you're on the right track :)
Usually a compiler has a way to either invoke the preprocessor
separately, to stop its processing after the preprocessor run or to
output and/or preserve the file contents after the preprocessor went
over it. This can help a lot figuring out what the preprocessor does.
Again, your compiler's manual should show you how to do this.
Gerhard
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist