iron261 / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

Problems with include files in 2.0.0 #207

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
While getting poppler to work with openjpeg 2.0.0 I have been getting some 
compiler error and warnings.

In file included from /usr/local/include/openjpeg-2.0/openjpeg.h:92:0,
                 from JPEG2000Stream2.h:18,
                 from JPEG2000Stream2.cc:15:
/usr/local/include/openjpeg-2.0/opj_stdint.h:46:9: error: 'size_t' does not 
name a type
In file included from JPEG2000Stream2.h:18:0,
                 from JPEG2000Stream2.cc:15:
/usr/local/include/openjpeg-2.0/openjpeg.h:479:20: error: ISO C++ forbids 
declaration of 'OPJ_SIZE_T' with no type [-fpermissive]
/usr/local/include/openjpeg-2.0/openjpeg.h:479:20: error: typedef 'OPJ_SIZE_T' 
is initialized (use decltype instead)
/usr/local/include/openjpeg-2.0/openjpeg.h:479:23: error: 'opj_stream_read_fn' 
was not declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:484:20: error: ISO C++ forbids 
declaration of 'OPJ_SIZE_T' with no type [-fpermissive]
/usr/local/include/openjpeg-2.0/openjpeg.h:484:20: error: typedef 'OPJ_SIZE_T' 
is initialized (use decltype instead)
/usr/local/include/openjpeg-2.0/openjpeg.h:484:23: error: 'opj_stream_write_fn' 
was not declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:993:54: error: 'OPJ_SIZE_T' was not 
declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:993:89: error: expected 
primary-expression before 'p_is_input'
/usr/local/include/openjpeg-2.0/openjpeg.h:993:99: error: expression list 
treated as compound expression in initializer [-fpermissive]
/usr/local/include/openjpeg-2.0/openjpeg.h:1008:80: error: 'opj_stream_read_fn' 
has not been declared
/usr/local/include/openjpeg-2.0/openjpeg.h:1015:81: error: 
'opj_stream_write_fn' has not been declared
/usr/local/include/openjpeg-2.0/openjpeg.h:1052:75: error: 'FILE' was not 
declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:1052:82: error: 'p_file' was not 
declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:1052:99: error: expected 
primary-expression before 'p_is_read_stream'
/usr/local/include/openjpeg-2.0/openjpeg.h:1052:115: error: expression list 
treated as compound expression in initializer [-fpermissive]
/usr/local/include/openjpeg-2.0/openjpeg.h:1060:67: error: 'FILE' was not 
declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:1060:74: error: 'p_file' was not 
declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:1060:82: error: 'OPJ_SIZE_T' was not 
declared in this scope
/usr/local/include/openjpeg-2.0/openjpeg.h:1060:117: error: expected 
primary-expression before 'p_is_read_stream'
/usr/local/include/openjpeg-2.0/openjpeg.h:1060:133: error: expression list 
treated as compound expression in initializer [-fpermissive]

The problem is openjpeg.h is using types like size_t and FILE* without 
including the appropriate header files. I can fix the problem by putting a 
#include <stdio.h> before the #include <openjpeg.h> but I should not have to do 
this.

I've also been getting this warning:

/usr/local/include/openjpeg-2.0/opj_config.h:22:0: warning: "HAVE_FSEEKO" 
redefined

because config.h in poppler has already defined HAVE_FSEEKO. I'm not sure why 
openjpeg is polluting public header files with commonly used #defines. I could 
not see where HAVE_FSEEKO is used in any of the openjpeg public header files.

I have not tried building with windows however I expect the stdint types 
defined in opj_stdint.h will cause problems with duplicate type definitions 
since poppler and other projects have also created the stdint types on windows. 

The openjpeg header files should ensure that all public symbols and macros are 
prefixed with opj to avoid name space collisions.

Original issue reported on code.google.com by adrian.j...@gmail.com on 1 Jan 2013 at 2:22

GoogleCodeExporter commented 9 years ago
Hi,

Could you try with the last trunk revision please. I think to have corrected 
this point.
Best
Mickaël

Original comment by savmick...@gmail.com on 3 Feb 2013 at 6:16

GoogleCodeExporter commented 9 years ago
I tested with trunk and the missing stdio.h bug is fixed. The missing 
pkg-config file bug has also been fixed.

However the problem of including config.h in a public header still exists. This 
is a really bad idea as described here http://inaugust.com/post/68 . 

There is also the typedef of the stdint types on WIN32 which will conflict with 
any project that has their own definition for these types. According to my copy 
of Harbison & Steele identifiers beginning with int or uint and ending with _t 
are reserved by Standard C. In addition POSIX reserves all identifiers ending 
with _t 
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html) 
although you can usually get away with it providing you use a project specific 
prefix.

Original comment by adrian.j...@gmail.com on 4 Feb 2013 at 10:40

GoogleCodeExporter commented 9 years ago
ok thanks for your return.
I understand your point of view for int definitions.
For config.h I will try to check why we have decided to install this file.

Original comment by savmick...@gmail.com on 4 Feb 2013 at 12:29

GoogleCodeExporter commented 9 years ago
I had a look at what is in opj_config.h and the only thing that is being used 
is OPJ_HAVE_STDINT_H. You could easily remove both opj_config.h and 
opj_stdint.h and replace them with the attached patch. The OPJ_HAVE_STDINT_H 
macro is not adding any value since if stdint.h is not available and the 
platform is not windows the build errors out. So you may as well just have the 
bare #include <stdint.h> for non windows platforms.

Also, are the exact width types really needed or do you only need a minimum 
guaranteed size? The types are not used consistently throughout the header. In 
the structs the standard types (char, int etc) are mixed with fixed width types.

Original comment by adrian.j...@gmail.com on 5 Feb 2013 at 12:22

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Can you take a look to my github 
https://github.com/savmickael/openjpeg-msd/tree/issue_207. I provide a proposal 
about this issue.
Mickaël

Original comment by savmick...@gmail.com on 10 Apr 2013 at 9:13

GoogleCodeExporter commented 9 years ago
Building on Linux now works fine. I think that defining the stdint types on 
windows will cause problems for applications that define their own stdint types.

Since the stdint types are only used to create the OPJ_* types you could easily 
avoid defining stdint types on windows and create the OPJ_* types directly from 
the windows __int* types.

It would be good to get a new release out with this and the pkg-config fix so 
poppler can start using openjpeg 2.

Original comment by adrian.j...@gmail.com on 24 Aug 2013 at 6:53

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 25 Feb 2014 at 3:31

GoogleCodeExporter commented 9 years ago

Original comment by mathieu.malaterre on 25 Feb 2014 at 3:32

GoogleCodeExporter commented 9 years ago
As per OP report, all issues have been fixed now. closing.

Original comment by mathieu.malaterre on 27 Feb 2014 at 10:21