[英]Typedef error in C++
I am trying to use a library from my Qt project that has both C and C++ variants.我正在尝试使用我的 Qt 项目中的一个库,该项目同时具有 C 和 C++ 变体。
if I include the C ".h" file, it seems like I can use that ok.如果我包含 C “.h” 文件,似乎我可以使用它。 However, to stick with the style of my C++ QT project, I wanted to use the ".hpp" C++ version.
然而,为了坚持我的 C++ QT 项目的风格,我想使用“.hpp” C++ 版本。
I am getting an error in this block of code from one of the libraries header files:我在来自 header 文件的库之一的这段代码中遇到错误:
#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.定义 SemaphorePosix typedef 的行是发生错误的地方,但是我在编译几个不同的 header 文件时遇到了类似的错误,这些文件正在执行这种相同的条件包含/类型定义。
Just to be specific, the error on compilation is "'SemaphorePosix' does not name a type"具体来说,编译时的错误是“'SemaphorePosix'没有命名类型”
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此外,应该可以访问 sys/*.h - 我在包含路径中有关于库包含文件夹中 sys 文件夹的顶层
Have you tried ::SemaphorePosix
?你试过
::SemaphorePosix
吗? Or maybe this type is defined inside another namespace.或者这个类型可能是在另一个命名空间中定义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.