This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there conditional compilation depending on the project?

Hi there!

In a few weeks, I might have to derive a product from another products. The hardware is the same, but the software is slightly different.

I think, it would be a drag to copy the sources to another directory and and take care of two code versions.

So it would be nice to know, which project it is while compilation time, so that I could use some #ifdef statement to get conditional compilation.

Other than that, I just had the idea to have a "higher source level files that define a compiler constant and then include the low level source files.

Like:


"highlevel.c"
#define OEM
#include "lowlevel.c"

"lowlevel.c"
#ifdef OEM
#include ...
#else
#include ...
#endif

// some common source

#ifdef OEM
// OEM source only
#else
// non OEM source
#endif

// some common source

Then I only need a different linker file to get different fuctions, but only one source file set.

Is there any better way?

Thanks,
Sven

Parents
  • Here is my experience. (In other words why I gave up on targets and now make separate UV2 projects.)

    UV2 is "different" than other IDE's.

    In other IDE's you create "targets" each having there own "file source list" (and options).

    In the UV2 IDE's you create one "file source list" which contain "targets" that have there own "exclude from the build list" (and options).

    In other words all "targets" share the same file list. To remove a file you must leave it in the list and set "exclude from the build flag". To add a file you must add it and then go to all the other "targets" and set their "exclude from the build flag".

Reply
  • Here is my experience. (In other words why I gave up on targets and now make separate UV2 projects.)

    UV2 is "different" than other IDE's.

    In other IDE's you create "targets" each having there own "file source list" (and options).

    In the UV2 IDE's you create one "file source list" which contain "targets" that have there own "exclude from the build list" (and options).

    In other words all "targets" share the same file list. To remove a file you must leave it in the list and set "exclude from the build flag". To add a file you must add it and then go to all the other "targets" and set their "exclude from the build flag".

Children