NCBI Toolkit & IBM DB2 – asn.h

December 17th, 2009

While working on code for my Influenza Sequence Mapping Project [url] I ran into a frustrating incompatibility between the IBM DB2 Embedded SQL C client [url] and the NCBI Toolbox [url].  Both of these APIs contain a header file named “asn.h.”  By chance I had been setting my preprocessor include path as:

export CPPFLAGS=”-I/usr/include/ncbi -I/home/db2inst1/sqllib/include”

With the NCBI Toolbox listed first in the include path the asn.h from that API was being read.  In my user code this worked out fine since I wasn’t making use of the asn.h from the IBM DB2 client.  Unfortunately, while setting up a new sandbox for development I happened to switch the order of the directories:

export CPPFLAGS=”-I/home/db2inst1/sqllib/include -I/usr/include/ncbi”

With this seemingly inconsequential change the code would no longer compile.  The simple statement #include <blast.h> which worked in the first case now led to compilation errors.  The header include chain in the NCBI Toolbox was now reading asn.h from IBM DB2 rather than the NCBI one that was needed.  Finding the cause of this error was difficult because the compiler did not report which asn.h was being included and I was working under the assumption that only one (the NCBI one) was available.  In fact I needed assistance from NCBI Support to realize that IBM DB2 was covering the NCBI header.

Now recognizing the problem I realized that I might be inadvertently covering header files all over the place and in some cases such coverages might be introducing insidious bugs that are not detected at compilation.  Indeed the issue of non-unique header file names is documented by CERT in the “CERT C Secure Coding Standard [url]” as “PRE08-C. Guarantee that header file names are unique [url].”  Instances of this problem should be easily detectable by the preprocessor by searching the include path and reporting a warning or error if an #include directive has made an ambiguous request.  I have filed GCC Bug 42407 [url] as an enhancement request for such a feature.

This entry was posted on Thursday, December 17th, 2009 at 2:44 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply