Shop OBEX P1 Docs P2 Docs Learn Events
mysterious ifdef/define error in FlexSpin — Parallax Forums

mysterious ifdef/define error in FlexSpin

Maybe it is my fault misunderstanding it or I stumbled over something.

I have a main spin file where I define either of one

define W5100

or

define W5200

or

define W6100

in the same file I can do this in the object section

OBJ

ifdef W5100

wiz : "ms_W5100.spin2"

endif

ifdef W5200

wiz : "ms_W5200.spin2"

endif

ifdef W6100

wiz : "ms_W6100.spin2"

endif

cool.

now the main file uses other objects also including the wiznet driver

So main includes "socket" and socket includes also the wiz and I can do the same and it recognizes the define and selects the correct driver.

main also includes "dns" and dns also includes socket. And here it gets borked.

so MAIN-SOCKET-WIZ works
but MAIN-DNS-SOCKET-WIZ does not and socket does not now about the define and does not find the correct WIZ

To me it looks like the define is valid in main and all included objects of main but not inside objects inside of those.

what do I do wrong?

MAIN, SOCKET and DNS have the same code like above in the OBJ section.

Mike

Comments

  • #define only has any effect in the source file where it happens -- it isn't carried over into any sub-objects. All of the preprocessor commands work similarly to how they do in C, namely they go on a file by file basis.
    You can get a define in all files by doing it on the flexspin command line (with -DSYMBOL=x).

  • that explains my trouble...

    Mike

Sign In or Register to comment.