开发者

Typedef error in C++

I am trying to use a library from my Qt project that has both C and C++ variants.

if I include the C ".h" file, it seems like I can use that ok. Howe开发者_开发问答ver, to stick with the style of my C++ QT project, I wanted to use the ".hpp" C++ version.

I am getting an error in this block of code from one of the libraries header files:

#ifndef __SYS_SEMAPHORE_H__
#define __SYS_SEMAPHORE_H__ 
/**
 *  \file 
 *  \brief Include the right semaphore.
 *
 *  This file will auto-select the semaphore of choice,
 *  if one is to be defined.  
 *  \note We need to change the windows part to check _MT
 *  because that is how it determines reentrance!
 *
 */
#  if defined(_REENTRANT)

#    if defined(USE_NSPR_THREADS)
#        include "sys/SemaphoreNSPR.h"
namespace sys
{
typedef SemaphoreNSPR Semaphore;
}
// If they explicitly want posix
#    elif defined(__POSIX) && !defined(__APPLE_CC__)
#        include "sys/SemaphorePosix.h"
namespace sys
{
typedef SemaphorePosix Semaphore;
}
#    elif defined(WIN32)
#        include "sys/SemaphoreWin32.h"
namespace sys
{
typedef SemaphoreWin32 Semaphore;
}
#    elif defined(__sun) && !defined(__POSIX)
#        include "sys/SemaphoreSolaris.h"
namespace sys
{
typedef SemaphoreSolaris Semaphore;
}
#    elif defined(__sgi) && !defined(__POSIX)
#        include "sys/SemaphoreIrix.h"
namespace sys
{
typedef SemaphoreIrix Semaphore;
}
#    elif defined(__APPLE_CC__)
typedef int Semaphore;
#    else
#        include "sys/SemaphorePosix.h"
namespace sys
{
typedef SemaphorePosix Semaphore;
}
#    endif // Which thread package?

#  endif // Are we reentrant?

#endif // End of header

The line defining SemaphorePosix typedef is where the error is happening, but I am getting this similar error in compilation across a few different header files that are doing this same sort of conditional including/typedef'ing.

Just to be specific, the error on compilation is "'SemaphorePosix' does not name a type"

Also, sys/*.h should be able to be reached - I have in the include path the top level about the sys folder from the libraries include folder


Have you tried ::SemaphorePosix? Or maybe this type is defined inside another namespace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜