繁体   English   中英

C++ 中的类型定义错误

[英]Typedef error in C++

我正在尝试使用我的 Qt 项目中的一个库,该项目同时具有 C 和 C++ 变体。

如果我包含 C “.h” 文件,似乎我可以使用它。 然而,为了坚持我的 C++ QT 项目的风格,我想使用“.hpp” C++ 版本。

我在来自 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

定义 SemaphorePosix typedef 的行是发生错误的地方,但是我在编译几个不同的 header 文件时遇到了类似的错误,这些文件正在执行这种相同的条件包含/类型定义。

具体来说,编译时的错误是“'SemaphorePosix'没有命名类型”

此外,应该可以访问 sys/*.h - 我在包含路径中有关于库包含文件夹中 sys 文件夹的顶层

你试过::SemaphorePosix吗? 或者这个类型可能是在另一个命名空间中定义的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM