ctime std::命名空间冲突
ctime std:: namespace conflict
我有很多C和C++文件的项目。我尝试添加线程安全队列。在我的标题中:
#include <queue>
#include <mutex>
#include <thread>
#include <condition_variable>
// Some code..
当我尝试编译它时,它的错误是这个错误:
In file included from /usr/include/c++/4.9/chrono:41:0,
from /usr/include/c++/4.9/mutex:39,
from queue.hpp:4,
from main.cpp:24:
/usr/include/c++/4.9/ctime:60:11: error: '::clock_t' has not been declared
using ::clock_t;
/usr/include/c++/4.9/condition_variable:161:23: error: 'time_t' in namespace 'std' does not name a type
static_cast<std::time_t>(__s.time_since_epoch().count()),
据我了解,编译器试图找到 std::time_*,但为什么呢?如何解决它?谢谢!
UPD:主要.cpp
#include "gpu.hpp" //Error here
int main(int argc, char const *argv[]) {
return 0;
}
GPU .hpp
#pragma once
#include "filter.hpp"
#include "queue.hpp" //Error here
#include <nvcuvid.h>
#include <avformat.h>
#include <vector>
队列.hpp
#pragma once
#include <queue>
#include <mutex>
#include <thread>
#include <condition_variable>
template<typename T>
class CQueue
{
std::queue<T> m_queue;
std::mutex m_mutex;
std::condition_variable m_cond;
// ...
第一条错误消息:
In file included from queue.hpp:3:0,
from gpu.hpp:3,
from main-test.cpp:2:
/usr/include/c++/4.9/ctime:60:11: error: '::clock_t' has not been declared
using ::clock_t;
制作文件:
FFMPEG_INCLUDES := -I$(FFMPEG_PATH) $(FFMPEG_PATH)/libavutil ...
$(OBJECTS_DIRS)/app-main-test.o: src/app/main-test.cpp
$(CXX) $(CXXFLAGS) $(FFMPEG_INCLUDES) $(CUDA_INCLUDES) -o $@ -c $<
问题出在我的制作文件中。我包含每个 ffmpeg 文件夹的路径。 FFMPEG_INCLUDES := -I$(FFMPEG_PATH) $(FFMPEG_PATH)/libavutil ...
FFMPEG 有 time.c 在ffmpeg/libavutil
它会导致与 ctime 的冲突。
我将#include <log.h>
替换为#include<libavutil/log.h>
并修复了makefile中的包含路径FFMPEG_INCLUDES := -I$(FFMPEG_PATH)
谢谢@user2807083的帮助。
相关文章:
- 如何使 std::sort 在 std::swap 和我的命名空间的模板化交换之间没有名称冲突?
- C++ |匿名命名空间与命名空间 std 冲突
- 分解SWIG Python接口 - 容器会产生命名空间冲突
- 如何解决两个不使用命名空间的第三方库之间的类名冲突?
- 调用 ADL 时,表达式和命名空间之间是否会发生冲突
- 类名和枚举值之间的冲突:无需命名空间即可解析
- C++当命名空间、类名和命名空间::类名冲突时该怎么办
- C++ 中的命名空间冲突
- 避免与具有相同名称的两个类发生命名空间冲突
- 命名与多个命名空间冲突
- 命名空间中的类名冲突
- ctime std::命名空间冲突
- 如何避免 C 和 C++ 中的命名空间冲突
- C++ 当命名空间发生冲突时,为什么结构/类不与变量和函数发生冲突?
- 我收到void main()和使用命名空间std;之间的冲突;?我正在使用代码块
- 全局作用域枚举和命名空间冲突
- 如何解决c++中的命名空间冲突?
- 不明确的引用和命名空间(来自两个外部库的定义冲突)
- 命名空间,类成员ADL冲突
- 在c++中命名命名空间的最佳方法//当名称冲突时该怎么做