ed wrote:
> Hi,
> 
> A small project that I've been working on was buildable for
> linux/openbsd through a Makefile. The Makefile would build with one of
> two .c files. This worked fine as the same function names were used in
> both files.
> 
> Now I'm wanting to add optional mysql/postgres/sqllite etc to the
> project but I don't know how I can specify these as optionals, for
> example, the libraries may not exist to link to. Is there a way to set
> a define value in the Makefile that can be passed to the compiler?

Usually a '-dDATABASE' sort of option.  'man gcc'...


> Ideally in the code, I would have something like:
> 
> #ifdef DATABASE
>   call_database_routeine();
> #enfif
> 
> .. at bit of a loss here!

Have you considered dynamically loading libraries at runtime?  That 
would allow you to compile in support and then it would automatically 
work if the library was available.

(I've got some really impressive macros I use _extensively_ to manage 
dynamically loaded libraries.  I've been debating the inclusion of these 
macros into Safe C++.)

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to