title: How do I force the linker to reject particular libraries without the libraries themselves conflicting?
body: <p>I'm trying to add a sanity check at the link stage.  Specifically, I have programs that are statically linking libraries.  Some programs are limited to the set of libraries allowed to be linked while others are not.  So say for example I have two programs respectively from <code>food.c</code> and <code>fruits.c</code>, and I have two libraries (for which I have source) <code>apple.a</code> and <code>broccoli.a</code>.  There is no dependency between <code>apple.a</code> and <code>broccoli.a</code>.</p>
  
  <p>Is there a way I can modify my source and the libraries' source such that the linker will allow me to link both <code>apple.a</code> and <code>broccoli.a</code> into <code>food.c</code>, and will allow me to link <code>apple.a</code> into <code>fruits.c</code>, but will produce a linker error when I try to load <code>apple.a</code> and <code>broccoli.a</code> (or just <code>broccoli.a</code>) into <code>fruits.c</code>?  Assume that my source does not <code>#include</code> any headers in the libraries they link, as they are linked in by mistake, are left over from deleted code, function prototypes are manually declared, and so on.</p>
  
  <p>What would be nice is if I could somehow tag these libraries in such a way that my program can reject a particular tag.</p>
  
  <p>The specific compiler I'm using does not implement <code>#pragma poison</code>, which was really the only helpful tool I've found in my search.  My hunch tells me there might be something clever I can do with weak symbols, but I'm not exactly sure what or how.</p>
  
  <p>I also don't believe using <code>#define</code> will help me, as my understanding is that would only prevent me from <code>#include</code>ing specific files, but if I'm mistaken in that, then that could also be a fine solution.</p>