Export to GitHub

openjpeg - issue #19

openjpeg.h causes build errors on powerpc + altivec hosts


Posted on Mar 20, 2010 by Happy Monkey

on powerpc hosts running gcc and utilizing altivec, the stdbool types are defined to take advantage of the hardware. however, this requires headers include stdbool.h to get the optimized definitions.

openjpeg.h relies on an external define (HAVE_STDBOOL_H) in order to determine whether to pull in stdbool.h. if this doesnt exist, it falls back to redefining the stdbool interfaces. this causes problems because the stdbool namespace is in the compiler / C library realm and arbitrary packages shouldnt be doing this kind of thing.

specifically, this code:

include <openjpeg.h>

include <stdbool.h>

will fail on a powerpc host like so: In file included from test.c:1: /usr/include/openjpeg.h:246: error: expected specifier-qualifier-list before ‘bool’ /usr/include/openjpeg.h:406: error: expected specifier-qualifier-list before ‘bool’ /usr/include/openjpeg.h:440: error: expected specifier-qualifier-list before ‘bool’ /usr/include/openjpeg.h:454: error: expected specifier-qualifier-list before ‘bool’ /usr/include/openjpeg.h:463: error: expected specifier-qualifier-list before ‘bool’ /usr/include/openjpeg.h:891: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘opj_encode’ /usr/include/openjpeg.h:900: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘opj_encode_with_info’

so the solution imo is to do the stdbool.h check at build time and mung the installed header so that it has an '#if 1' or '#if 0'. so something like: openjpeg.h:#if @HAVE_STDBOOL_H@ install: sed -e 's:@HAVE_STDBOOL_H@:$(HAVE_STDBOOL_H):' openjpeg.h > /installpath/....

Comment #1

Posted on Apr 8, 2010 by Grumpy Camel

Hi, could you check the latest revision and update your comment ?

The code is now more complete

ifndef __cplusplus

if defined(HAVE_STDBOOL_H)

/* The C language implementation does correctly provide the standard header file "stdbool.h". */

include

else

/* The C language implementation does not provide the standard header file "stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this braindamage below. */

if !defined(bool)

define bool int

endif

if !defined(true)

define true 1

endif

if !defined(false)

define false 0

endif

endif

endif /* __cplusplus */

Comment #2

Posted on Apr 9, 2010 by Happy Monkey

i dont think that makes any difference to my original report. openjpeg.h still requires someone to either manually include stdbool.h first or manually define HAVE_STDBOOL_H before including openjpeg.h. neither of these are generally accepted practices wrt library behavior and makes testing for header/library existence in standard build systems (like autotools) painful.

Comment #3

Posted on Apr 26, 2010 by Grumpy Camel

Hi,

Could you suggest a patch to correct this issue ?

Comment #4

Posted on Nov 15, 2010 by Swift Ox

What are the platforms that don't have stdbool.h?

Comment #5

Posted on May 10, 2011 by Massive Kangaroo

This patch fixes the issue when using cmake. I didn't do a version for autotools, because Gentoo uses the cmake build system, but vapier's suggestion should work fine. Hope this helps.

Attachments

Comment #6

Posted on May 18, 2011 by Happy Rabbit

Hi,

Thanks for the patch. Eventually, we have opted for a more "radical" solution: define a new type opj_bool, and two constants OPJ_FALSE and OPJ_TRUE. See r778 for more details.

Comments welcome.

Cheers,

Antonin

Comment #7

Posted on May 26, 2011 by Happy Rabbit

(No comment was entered for this change.)

Status: Fixed

Labels:
Type-Defect Priority-Medium