tags:

views:

109

answers:

3

I have a nice clean standards-compliant codebase that I can compile with GCC's "-ansi -pedantic-errors -Wextra", etc.

But now I need to use a source library with associated headers that is decidedly NOT clean code.

What's the best way to isolate this code from my own so that I can still compile mine strictly, but can allow leniency with the third-party code?

+3  A: 

There is no good way.

You could re-write the source library headers, being careful to maintain all call types and returns types. A lot of work.

You could front-end the library with a library of your own, that was just a pass-through. A lot more work.

You could isolate the use of the library to just a few of your modules. Then, compile these modules with relaxed options. How much work this is depends on the way your application is written. This might be the best way.

kmarsh
+2  A: 

Structure your build environment such that you have dependency from your good code to the bad library code. Further, ensure that the dependency is resolved by building the library code in a separate compilation with different options. This will allow you to build the two separately, yet express the dependency, which will achieve building the whole project with single command. I'm being abstract, since I don't know your build environment. Assuming you are using makefiles, you can play around a bit with targets and achieve this.

Nasko
A: 

Compile the library statically before your project. Make your project refer to the library headers and link against it.

If the library headers are really awful just write some simple wrappers around them.

IlDan