Skip to content

Commit

Permalink
Changes all #include "esl_config.h" to #include <esl_config.h>
Browse files Browse the repository at this point in the history
If you are using both a source tree and build tree(s), and you have
done a `configure` in both, build tree compilation includes the wrong
autoconf config.h file, from the source tree.

That's because having `#include "config.h"` in foo.c, with double
quotes, will attempt to find config.h in the directory that foo.c is
in (i.e. the source tree), before the -I include directory options are
checked.  Having `#include <config.h>`, with angle brackets, means
that only system include directories and directories explicitly listed
with -I will be searched. Directories are searched in the order of the
-I's on the cc compile line, so we put the build -I include directory
before the source.

This issue is unique to config.h files generated in the build tree by
./configure. All the other .h files are in the source tree.

I had never appreciated this difference between using quotes and angle
brackets, but it is indeed documented in the GNU autoconf manual, that
they recommend using angle brackets on #include <config.h> for exactly
this reason.

This fix replaces all #include "esl_config.h" with #include <esl_config.h>.

(xref SRE:2023/0807-h3-config-include-conflict)
  • Loading branch information
cryptogenomicon committed Aug 7, 2023
1 parent 285230b commit 3534b76
Show file tree
Hide file tree
Showing 196 changed files with 258 additions and 252 deletions.
22 changes: 14 additions & 8 deletions documentation/codestyle.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ For example, this is the top of start of `esl_json`:
* www.json.org
* tools.ietf.org/html/rfc8259
*/
#include "esl_config.h"
#include <esl_config.h>

The short table of contents description lines are repeated in comments
at the top of each section later in the file, facilitating
Expand All @@ -163,17 +163,23 @@ of external functions from the .c file.
The first include is a project-wide configuration header named
`<project_prefix>_config.h`. It must be included first, because it
may contain configuration constants that affect the behavior of other
headers, even including system headers. System headers come next,
because they might contain configuration that affects our
headers. Finally come our headers. I tend to group our headers
together by project, and alphabetize them, but (aside from the
project-wide config.h) our headers don't depend on any particular
headers, even including system headers. It must be included with angle
brackets, not double quotes, so compilation commands can control the
order that -I include directories are searched (build tree first,
source tree last), to assure that we don't erroneously use a stray
previous config file in the source tree when we're building in a build
tree.

System headers come next, because they might contain configuration
that affects our headers. Finally come our headers. I tend to group
our headers together by project, and alphabetize them, but (aside from
the project-wide config.h) our headers don't depend on any particular
inclusion order.

For example:


#include "h4_config.h"
#include <h4_config.h>

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -199,7 +205,7 @@ included once during compilation, regardless of the order of
```
#ifndef eslJSON_INCLUDED
#define eslJSON_INCLUDED
#include "esl_config.h"
#include <esl_config.h>
/* ...contents here... */
Expand Down
2 changes: 1 addition & 1 deletion easel.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* 11. Test driver.
* 12. Examples.
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion easel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
#ifndef eslEASEL_INCLUDED
#define eslEASEL_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include <stdlib.h>
#include <stdio.h> /* for FILE */
Expand Down
2 changes: 1 addition & 1 deletion esl_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* 4. Unit tests
* 5. Test driver
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_alphabet.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* 5. Test driver.
* 6. Examples.
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_alphabet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*/
#ifndef eslALPHABET_INCLUDED
#define eslALPHABET_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include <ctype.h> /* isascii() */
#include "easel.h"
Expand Down
2 changes: 1 addition & 1 deletion esl_arr2.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "esl_config.h"
#include <esl_config.h>

#include <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_arr3.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "esl_config.h"
#include <esl_config.h>

#include <stdlib.h>
#include <string.h>
Expand Down
6 changes: 3 additions & 3 deletions esl_avx.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* about empty translation units and no symbols, and dummy drivers
* that do nothing but declare success.
*/
#include "esl_config.h"
#include <esl_config.h>
#ifdef eslENABLE_AVX

#include <stdio.h>
Expand Down Expand Up @@ -43,7 +43,7 @@ esl_avx_dump_256i_hex4(__m256i v)
*****************************************************************/
#ifdef eslAVX_BENCHMARK

#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -200,7 +200,7 @@ utest_hmax_epi16(ESL_RANDOMNESS *rng)
*****************************************************************/

#ifdef eslAVX_TESTDRIVE
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <math.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_avx.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
#ifndef eslAVX_INCLUDED
#define eslAVX_INCLUDED
#include "esl_config.h"
#include <esl_config.h>
#ifdef eslENABLE_AVX

#include "easel.h"
Expand Down
4 changes: 2 additions & 2 deletions esl_avx512.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* about empty translation units and no symbols, and dummy drivers
* that do nothing but declare success.
*/
#include "esl_config.h"
#include <esl_config.h>
#ifdef eslENABLE_AVX512

#include <stdio.h>
Expand Down Expand Up @@ -110,7 +110,7 @@ utest_hmax_epi16(ESL_RANDOMNESS *rng)
*****************************************************************/

#ifdef eslAVX512_TESTDRIVE
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <math.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_avx512.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#ifndef eslAVX512_INCLUDED
#define eslAVX512_INCLUDED
#include "esl_config.h"
#include <esl_config.h>
#ifdef eslENABLE_AVX512

#include "easel.h"
Expand Down
2 changes: 1 addition & 1 deletion esl_bitfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2. Unit tests
* 3. Test driver
*/
#include "esl_config.h"
#include <esl_config.h>

#include <string.h>

Expand Down
2 changes: 1 addition & 1 deletion esl_bitfield.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef eslBITFIELD_INCLUDED
#define eslBITFIELD_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include "easel.h"

Expand Down
6 changes: 3 additions & 3 deletions esl_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/*::cexcerpt::header_example::end::*/

/*::cexcerpt::include_example::begin::*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -1889,7 +1889,7 @@ buffer_counttok(ESL_BUFFER *bf, const char *sep, esl_pos_t *ret_nc)
/* compile: gcc -g -Wall -I. -L. -o esl_buffer_benchmark -DeslBUFFER_BENCHMARK esl_buffer.c -leasel -lm
* run: ./esl_buffer_benchmark
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <fcntl.h>
Expand Down Expand Up @@ -2783,7 +2783,7 @@ utest_halfnewline(void)
* (gcov): gcc -g -Wall -fprofile-arcs -ftest-coverage -I. -L. -o esl_buffer_utest -DeslBUFFER_TESTDRIVE esl_buffer.c -leasel -lm
* run: ./esl_buffer_utest
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>

Expand Down
2 changes: 1 addition & 1 deletion esl_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*/
#ifndef eslBUFFER_INCLUDED
#define eslBUFFER_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>

Expand Down
6 changes: 3 additions & 3 deletions esl_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* 3. Test driver
* 4. Example
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdlib.h>

Expand Down Expand Up @@ -240,7 +240,7 @@ utest_singlelinkage(double *testdata, int n, double threshold, int *correct_assi
#ifdef eslCLUSTER_TESTDRIVE
/* gcc -g -Wall -o test -I. -L. -DeslCLUSTER_TESTDRIVE esl_cluster.c -leasel -lm
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <math.h>
Expand Down Expand Up @@ -286,7 +286,7 @@ main(int argc, char **argv)
#ifdef eslCLUSTER_EXAMPLE
/*::cexcerpt::cluster_example::begin::*/
/* gcc -g -Wall -o example -I. -L. -DeslCLUSTER_EXAMPLE esl_cluster.c easel.c -lm */
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
#ifndef eslCLUSTER_INCLUDED
#define eslCLUSTER_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

extern int esl_cluster_SingleLinkage(const void *base, size_t n, size_t size,
int (*linkfunc)(const void *, const void *, const void *, int *), const void *param,
Expand Down
2 changes: 1 addition & 1 deletion esl_composition.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "esl_config.h"
#include <esl_config.h>

#include "easel.h"
#include "esl_composition.h"
Expand Down
2 changes: 1 addition & 1 deletion esl_composition.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "esl_config.h"
#include <esl_config.h>

extern int esl_composition_BL62(double *f);
extern int esl_composition_WAG (double *f);
Expand Down
4 changes: 2 additions & 2 deletions esl_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* https://software.intel.com/en-us/articles/how-to-detect-knl-instruction-support
* https://en.wikipedia.org/wiki/CPUID
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -454,7 +454,7 @@ main(int argc, char **argv)
*****************************************************************/
#ifdef eslCPU_EXAMPLE

#include "esl_config.h"
#include <esl_config.h>

#include "easel.h"
#include "esl_cpu.h"
Expand Down
2 changes: 1 addition & 1 deletion esl_dirichlet.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* esl_mixdchlet : mixture Dirichlets
* esl_gamma: Gamma densities
*/
#include "esl_config.h"
#include <esl_config.h>

#include <assert.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_dirichlet.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
#ifndef eslDIRICHLET_INCLUDED
#define eslDIRICHLET_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include "esl_random.h"
#include "esl_fileparser.h" // Parameter input from file
Expand Down
2 changes: 1 addition & 1 deletion esl_distance.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* 8. Test driver.
* 9. Example.
*/
#include "esl_config.h"
#include <esl_config.h>

#include <ctype.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_distance.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
#ifndef eslDISTANCE_INCLUDED
#define eslDISTANCE_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include "easel.h"
#include "esl_alphabet.h"
Expand Down
2 changes: 1 addition & 1 deletion esl_dmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* - eventually probably want additional matrix types
* - unit tests poor
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_dmatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
#ifndef eslDMATRIX_INCLUDED
#define eslDMATRIX_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>

Expand Down
2 changes: 1 addition & 1 deletion esl_dsqdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* 8. Test driver
* 9. Examples
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_dsqdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*/
#ifndef eslDSQDATA_INCLUDED
#define eslDSQDATA_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <stdint.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_exponential.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* on failure due to small n. Compare esl_gumbel. xref J12/93.
* SRE, Wed Nov 27 11:03:07 2013
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include <math.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_exponential.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
#ifndef eslEXPONENTIAL_INCLUDED
#define eslEXPONENTIAL_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include "esl_histogram.h"
#include "esl_random.h"
Expand Down
2 changes: 1 addition & 1 deletion esl_fileparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* 4. Test driver.
* 5. Examples.
*/
#include "esl_config.h"
#include <esl_config.h>

#include <stdlib.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion esl_fileparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*/
#ifndef eslFILEPARSER_INCLUDED
#define eslFILEPARSER_INCLUDED
#include "esl_config.h"
#include <esl_config.h>

#include <stdio.h>
#include "easel.h"
Expand Down
Loading

0 comments on commit 3534b76

Please sign in to comment.