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
  • "There is no need to copy the files.
    You can simply enter the path (which can be relative) when you add the file to the Project"

    Yes, and no - if you have a version identifier in the path, it is a lot easier to copy *.c, *.h and *.a51 to a workfile than it is to change all path statements.

    Erik

Reply
  • "There is no need to copy the files.
    You can simply enter the path (which can be relative) when you add the file to the Project"

    Yes, and no - if you have a version identifier in the path, it is a lot easier to copy *.c, *.h and *.a51 to a workfile than it is to change all path statements.

    Erik

Children
No data