"ISO C++ forbids declaration of uchar with no type"

A

aneuryzma

Hello,

I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using
xCode.

When I add #include "openCVApp.h"

I got the following error:


"Applications/openCV/OpenCV.framework/Headers/cxtypes.h:549: error:
ISO C++ forbids declaration of 'uchar' with no type
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:549: error:
expected ';' before '*' token
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h: In function
'CvMat cvMat(int, int, int, void*)':
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:625: error:
'union CvMat::<anonymous>' has no member named 'ptr'
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:625: error:
'uchar' was not declared in this scope
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:625: error:
expected primary-expression before ')' token
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:625: error:
expected `;' before 'data'
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h: In function
'double cvmGet(const CvMat*, int, int)':
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:654: error:
'const union CvMat::<anonymous>' has no member named 'ptr'
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:658: error:
'const union CvMat::<anonymous>' has no member named 'ptr'
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h: In function
'void cvmSet(CvMat*, int, int, double)':
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:671: error:
'union CvMat::<anonymous>' has no member named 'ptr'
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:675: error:
'union CvMat::<anonymous>' has no member named 'ptr'
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h: At global
scope:
/Applications/openCV/OpenCV.framework/Headers/cxtypes.h:708: error:
ISO C++ forbids declaration of 'uchar' with no type
....
...
....


any suggestion ?
 
R

Roland Pibinger

I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using
xCode.

When I add #include "openCVApp.h"

I got the following error:

"Applications/openCV/OpenCV.framework/Headers/cxtypes.h:549: error:
ISO C++ forbids declaration of 'uchar' with no type

include the header that defines 'uchar' before openCVApp.h.
 
G

Greg Herlihy

include the header that defines 'uchar' before openCVApp.h.

Or, if no such header can be found, define the "uchar" typedef
yourself - before including openCVApp.h:

typedef unsigned char uchar;
// ...
#include "openCVApp.h"

Even if the header with the "uchar" typedef is eventually found and
included - having an extra "uchar" typedef in the same translation
unit should not be a problem. A C++ program is free to define the same
typedef, multiple times within a single scope - provided that the
typedef is defined the same way each time.

Greg
 
A

aneuryzma

Or, if no such header can be found, define the "uchar" typedef
yourself - before including openCVApp.h:

   typedef    unsigned char   uchar;
   // ...
   #include "openCVApp.h"

Even if the header with the "uchar" typedef is eventually found and
included - having an extra "uchar" typedef in the same translation
unit should not be a problem. A C++ program is free to define the same
typedef, multiple times within a single scope - provided that the
typedef is defined the same way each time.

Greg

Hi,

well I tried to add typedef unsigned char uchar; before but I still
have the same error.

The thing is that "typedef unsigned char uchar;" *IS* in a header file
in which i got the error. I don't understand why the compiler
complains that it is not defined.

This is the header:

#ifndef _CXCORE_TYPES_H_
#define _CXCORE_TYPES_H_

...

#ifndef HAVE_IPL
typedef unsigned char uchar;
typedef unsigned short ushort;
#endif

...

union
{
uchar* ptr; <-- error
short* s;
int* i;
float* fl;
double* db;
}

I also tried to remove the if condition before typedef but still have
the same error
 
A

aneuryzma

Hi,

well I tried to add typedef unsigned char uchar;  before but I still
have the same error.

The thing is that "typedef unsigned char uchar;" *IS* in a header file
in which i got the error. I don't understand why the compiler
complains that it is not defined.

This is the header:

#ifndef _CXCORE_TYPES_H_
#define _CXCORE_TYPES_H_

...

#ifndef HAVE_IPL
typedef unsigned char uchar;
typedef unsigned short ushort;
#endif

...

union
    {
        uchar* ptr; <-- error
        short* s;
        int* i;
        float* fl;
        double* db;
    }

I also tried to remove the if condition before typedef but still have
the same error

I just want to remark that everything works perfectly if I build only
the openCV application. I think there is some kind of conflict on the
uchar variable.
 
R

Roland Pibinger

The thing is that "typedef unsigned char uchar;" *IS* in a header file
in which i got the error. I don't understand why the compiler
complains that it is not defined.

This is the header:

#ifndef _CXCORE_TYPES_H_
#define _CXCORE_TYPES_H_


#ifndef HAVE_IPL <-- !!!
typedef unsigned char uchar;
typedef unsigned short ushort;
#endif

Do you define HAVE_IPL (e.g. -DHAVE_IPL in the makefile)?
 
P

Puppet_Sock

I just want to remark that everything works perfectly if I build only
the openCV application. I think there is some kind of conflict on the
uchar variable.

Right.

So what you want to do now is create the smallest possible
chunk of source code that demonstrates the error.

Make a copy of the source files. "Hand" do the includes
to get down to a single file that still shows the error.

Then start the old "divide and rule." Take out half the
source code and see if the error goes away. Bin-search
on it till you get down to five or ten lines or so.
Should not take you more than 10 or 15 divides.

If the error does not become obvious this way, post back
a short example.
Socks
 
A

aneuryzma

Right.

So what you want to do now is create the smallest possible
chunk of source code that demonstrates the error.

Make a copy of the source files. "Hand" do the includes
to get down to a single file that still shows the error.

Then start the old "divide and rule." Take out half the
source code and see if the error goes away. Bin-search
on it till you get down to five or ten lines or so.
Should not take you more than 10 or 15 divides.

If the error does not become obvious this way, post back
a short example.
Socks

Hi,

well, I think I solved just including openCV before and ogre3d later.

Do you know a cross-platform multithread *light* library that I can
use to run both application simultaneously ?

thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top