-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Description
System information (version)
- OpenCV => 2.4.9 (2.4.9.1+dfsg-1.5ubuntu1)
- Operating System / Platform => Ubuntu 16.04, 64 bit
- Compiler => GNU GCC 5.2
Detailed description
OpenCV has typedef in global namespace that will prevent compilation if other library has conflicting typedef. Currently, we are aware of one library (libgeos) that has conflicting typedef. We are going to submit similar bug report to libgeos.
// libgeos
typedef long long int int64;
// opencv
typedef int64_t int64;I am aware that this problem could be solved by compiling code in different compilation unit, but currently we have shared code that can't be separated (or at least not easily) in different compilation units. The only option in that case is to either mess with typedef, i.e.:
#define int64 opencv_broken_int
#include <opencv2/imgproc/imgproc.hpp>
#undef int64
#include <geos/geom/Coordinate.h>
int main(int, argc**)
{
return 0;
}or make wrapper interface and compile it different compilation units. Nevertheless, the nicest solution would be if opencv could stop using common typename like int64 in global namespace.
I am aware that using C++ namespace might not be option due to C interface, but at least prefixed typedef could be used, i.e. opencv_int64 / cv_int64 or similar. Such typedef would not break ABI, although it would change API.
We are ready to commit resources to this issue and provide a patch once we agree that this should be fixed and agree what is best approach to this issue.
Steps to reproduce
// sample.cpp
#include <geos/geom/Coordinate.h>
#include <opencv2/imgproc/imgproc.hpp>
int main(int, argc**)
{
return 0;
}$ g++ -c sample.cpp
In file included from /usr/include/opencv2/core/core.hpp:49:0,
from /usr/include/opencv2/imgproc/imgproc.hpp:50,
from sample.cpp:2:
/usr/include/opencv2/core/types_c.h:163:20: error: conflicting declaration ‘typedef int64_t int64’
typedef int64_t int64;
^
In file included from /usr/include/geos/geom/Coordinate.h:19:0,
from sample.cpp:1:
/usr/include/geos/platform.h:66:26: note: previous declaration as ‘typedef long long int int64’
typedef long long int int64;
^
sample.cpp:4:15: error: ‘argc’ has not been declared
int main(int, argc**)
^
sample.cpp:4:5: warning: second argument of ‘int main(int, int**)’ should be ‘char **’ [-Wmain]
int main(int, argc**)