error: redefinition of ‘xxx’问题的解决
来源:互联网 发布:网络狼人杀发言技巧 编辑:程序博客网 时间:2024/06/06 05:44
写点基础的东西。
C语言初学者一般会遇到重复定义的问题,比如:
message.h:36:16: error: redefinition of 'struct MSG_SERVOCTRL'
message.h:36:16: note: originally defined here
message.h:40:2: error: conflicting types for 'servoctrl'
message.h:40:2: note: previous declaration of 'servoctrl' was here
message.h:42:16: error: redefinition of 'struct MSG_PTZCTRL'
message.h:42:16: note: originally defined here
message.h:51:2: error: conflicting types for 'ptzctrl'
message.h:51:2: note: previous declaration of 'ptzctrl' was here
message.h:55:20: error: redefinition of 'cameractrl_params'
这个问题其实解决起来比较容易,一般是目标头文件.h没有加条件编译语句,语句的格式比较固定:
#ifndef _TEST_H_
#define _TEST_H_
。。。
#endif
把上面的代码加在头文件.h的头尾,即可避免重复定义的错误。
#include “xxx.h” 实际是将.h文件内容展开铺在.c文件之前,如果xxx.h没有加条件编译,那么重复引用和循环递归include时,就会展开多个重复的定义在.c代码之前,这样在编译的时候必然会有重复定义的告警。
比较基础,大牛略过。
0 0
- error: redefinition of ‘xxx’问题的解决
- c语言 error redefinition of 'xxx' 解决
- error redefinition of 'xxx' 问题解决
- error: redefinition of
- error: redefinition of ‘struct ifmap’ 和 redefinition of ‘struct ifreq’(linux/if.h和net/if.h重复定义的解决)
- 解决error C2011: 'fd_set' : 'struct' type redefinition问题
- C++ ERROR redefinition of ‘class ***’
- error: redefinition of 'struct iphdr'
- C++ ERROR redefinition of ‘class ***’
- C++ ERROR redefinition of ‘class ***’
- 解决error C2011: 'fd_set' : 'struct' type redefinition的方法
- 解决error C2011: 'fd_set' : 'struct' type redefinition的方法
- 解决error C2011: 'fd_set' : 'struct' type redefinition的方法
- 解决error C2011: 'fd_set' : 'struct' type redefinition的方法
- error C2371: 'XXX' : redefinition; different basic types 解决办法
- error C2371: 'XXX' : redefinition; different basic types 解决办法
- 简单的问题,用类创建一个对象error C2380: type(s) preceding 'Complex' (constructor with return type, or illegal redefinition of current class-n
- error C2011: 'fd_set' : 'struct' type redefinition问题
- CDN的基本工作过程
- oracle中sequence详解
- Android自定义属性实现图片屏幕的适配
- 模拟搭建Web项目的真实运行环境(三)
- Dragon Raja 语录
- error: redefinition of ‘xxx’问题的解决
- 线程基础篇
- 经典面试题之 —— 实现两个整数变量的交换
- 161218--lua学习 代码+笔记 基础篇2
- 滚动条:ScrollView和HorizontalScrollView
- 详解网络传输中的三张表,MAC地址表、ARP缓存表以及路由表
- 慕课网-JS动画实例学习笔记
- 进程的调度算法
- java 中的InetAddress类简单介绍