samtools / htslib

C library for high-throughput sequencing data formats
Other
799 stars 445 forks source link

std=c99 required by gcc 4.8.5 #1523

Closed lmjakt closed 1 year ago

lmjakt commented 1 year ago

I suspect that you may already be aware of the following, but if not perhaps it is useful to know:

I get the following errors and suggestions from gcc (4.8.5) when compiling hstlib, samtools or bcftools:

vcf.c:5109:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (int idx = 0; idx < sizeof(errdesc_bcf) / sizeof(err_desc); ++idx) {
     ^
vcf.c:5109:5: note: use option -std=c99 or -std=gnu99 to compile your code

they are solved by adding -std=gnu99 to the CFLAGS of the Makefiles of hstlib, samtools and bcftools.

I presume that this is specific to the version of gcc and hence not that important. Especially as it seems like there is a plan to specify std=c99 from looking at the htslib Makefile.

So this does not seem to be a problem per se, but I'm wondering whether there there is any potential problem with adding std=c99 or std=gnu99?

cheers,

Martin

daviesrob commented 1 year ago

It shouldn't cause a problem, as we do test builds with -std=c99. But thanks for reporting this, as we try to avoid putting declarations in for loops to keep early versions of gcc happy. Unfortunately it looks like one sneaked through here; we'll remove it.

lmjakt commented 1 year ago

Thanks for your reply and your efforts to keep htslib compatible across many compilers. I very much appreciate that style of coding.

cheers,

Martin