« Return to Thread: MPLAB Pre-processor

Re: MPLAB Pre-processor

by Tamas Rudnai :: Rate this Message:

Reply to Author | View in Thread

On Fri, Jun 26, 2009 at 1:32 AM, Justin Richards
<justin.richards@...>wrote:

> I agree with Olin.  I need help understanding difference between MPLAB and
> the c compiler (in this case c18) and you have helped.


MPLAB is only the IDE, while C18 is the compiler that IDE will invoke when
you do a build.


> 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.


You can invoke the compilation with command line using the MCC18.EXE located
in your MCC18 installation/bin directory, then you can apply -E option to
generate a "<filename>.i" file so you can see what the compiler will see
after the preprocessor.


> 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.


The directives are documented in the C18 user's manual. You can use that -E
option to see your values... However, I would not call it value, as #define
is only defining a macro which is a kind of replacement string. The
preprocessor only blindly replaces the string whatever you put after #define
MAX_TCP_SOCKETS so for example if you have a

myVar = MAX_TCP_SOCKETS;

in your code you will see

myVar = (9ul);

in the .i file... like a search and replace...

But in the .i file you will see NO #if statements whatsoever, those are
already preprocessed by that stage... You need to put a string that the
preprocessor can replace but will not remove or otherwise processes, so you
can even put a plain text without concerning of C language syntax therefore
would not compiled by C18 but at least can be used as a diagnostic on your
preprocessor experiments -- like:

...
...
...
>>> well, the current value of MAX-TCP-SOCKET: MAX_TCP_SOCKETS
...
...
...
(note that I replaces the original underscore to dash otherwise that string
would have been replaced by the preprocessor as well)

Tamas



>
> >From what Olin has said these must be c18 directives so I will go thru all
> the c18 help files and c what I can find.
>
> Cheers Justin
>
>
> Step back and understand the distinction between MPLAB, your C compiler,
> and
> > its preprocessor.  Until then things won't make any sense and you will
> > continue to ask questions that don't make sense.
> >
> >
> > ********************************************************************
> > Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
> > (978) 742-9014.  Gold level PIC consultants since 2000.
> > --
> > http://www.piclist.com PIC/SX FAQ & list archive
> > View/change your membership options at
> > http://mailman.mit.edu/mailman/listinfo/piclist
> >
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>



--
http://www.mcuhobby.com
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

 « Return to Thread: MPLAB Pre-processor