结算采集程序IDEPinf,C++源文件编译顺序的问题
来源:互联网 发布:12年伤感网络歌曲大全 编辑:程序博客网 时间:2024/06/03 15:57
结算采集程序IDEPinf
vector<CGatherEntity> g_vecGatherEntity;
m_GatherDao->ReadGatherInfo()
{
CGatherEntity gatherEntity;
g_vecGatherEntity.clear();g_vecGatherEntity.size:0 g_vecGatherEntity.capacity:0
g_vecGatherEntity.reserve(20);g_vecGatherEntity.size:11539302 g_vecGatherEntity.capacity:20
g_vecGatherEntity.resize(20);加入执行会core dump
g_vecGatherEntity.push_back(gatherEntity);执行会core dump
}
解决问题的思路:
1、自己写了一个程序,只做m_GatherDao->ReadGatherInfo();发现程序正常
2、在原有工程项目中,main() 函数也只做 m_GatherDao->ReadGatherInfo();程序core dump
3、剪裁程序去掉m_GatherDao->ReadGatherInfo();不涉及的所有.cpp 和.h程序正常
4、试着添加一个个.cpp .h 由于全局变量的关系,在编译过程中的报错,结果所有的.cpp 和.h 都一次性加进来了。程序正常
5、想了想,把编译顺序还原,然后把core dump 的vector<CGatherEntity> g_vecGatherEntity;的.cpp 编译顺序前移程序正常
判断问题:
1、是.cpp程序编译顺序的问题,导致程序core dump (程序中太多了全局变量,依赖关系复杂)。
2、因为g_vecGatherEntity 是全局变量,其他.cpp也会用到这个,是不是编译顺序的调整,是不是会改变变量的定义位置,当这个.cpp在后面编译,会导致其他程序在使用这个变量的时候,还没定义,程序core dump.???
错误顺序: 后面发现其实只要IDEPinf_CGatherDao.cpp 放到前面几个就不会core dump.
SRCS=CException.cpp comm_tool.cpp IDEPinf_CommTool.cpp IDEPinf_CBizFileCheck.cpp IDEPinf_CBizGather.cpp IDEPinf_CBizFindDupBill.cpp IDEPinf_CMainBusinessProcess.cpp IDEPinf_CFileDao.cpp IDEPinf_CGatherDao.cpp IDEPinf_CLogDao.cpp IDEPinf_FuncDef.cpp IDEPinf_main.cpp msg_tool.cpp OcciDataBase.cpp
正常顺序:
SRCS=CException.cpp comm_tool.cpp IDEPinf_CommTool.cpp IDEPinf_CGatherDao.cpp IDEPinf_main.cpp msg_tool.cpp OcciDataBase.cpp IDEPinf_CMainBusinessProcess.cpp IDEPinf_CBizFileCheck.cpp IDEPinf_CLogDao.cpp IDEPinf_CBizFindDupBill.cpp IDEPinf_CFileDao.cpp IDEPinf_FuncDef.cpp IDEPinf_CBizGather.cpp
vector<CGatherEntity> g_vecGatherEntity;
m_GatherDao->ReadGatherInfo()
{
CGatherEntity gatherEntity;
g_vecGatherEntity.clear();g_vecGatherEntity.size:0 g_vecGatherEntity.capacity:0
g_vecGatherEntity.reserve(20);g_vecGatherEntity.size:11539302 g_vecGatherEntity.capacity:20
g_vecGatherEntity.resize(20);加入执行会core dump
g_vecGatherEntity.push_back(gatherEntity);执行会core dump
}
解决问题的思路:
1、自己写了一个程序,只做m_GatherDao->ReadGatherInfo();发现程序正常
2、在原有工程项目中,main() 函数也只做 m_GatherDao->ReadGatherInfo();程序core dump
3、剪裁程序去掉m_GatherDao->ReadGatherInfo();不涉及的所有.cpp 和.h程序正常
4、试着添加一个个.cpp .h 由于全局变量的关系,在编译过程中的报错,结果所有的.cpp 和.h 都一次性加进来了。程序正常
5、想了想,把编译顺序还原,然后把core dump 的vector<CGatherEntity> g_vecGatherEntity;的.cpp 编译顺序前移程序正常
判断问题:
1、是.cpp程序编译顺序的问题,导致程序core dump (程序中太多了全局变量,依赖关系复杂)。
2、因为g_vecGatherEntity 是全局变量,其他.cpp也会用到这个,是不是编译顺序的调整,是不是会改变变量的定义位置,当这个.cpp在后面编译,会导致其他程序在使用这个变量的时候,还没定义,程序core dump.???
错误顺序: 后面发现其实只要IDEPinf_CGatherDao.cpp 放到前面几个就不会core dump.
SRCS=CException.cpp comm_tool.cpp IDEPinf_CommTool.cpp IDEPinf_CBizFileCheck.cpp IDEPinf_CBizGather.cpp IDEPinf_CBizFindDupBill.cpp IDEPinf_CMainBusinessProcess.cpp IDEPinf_CFileDao.cpp IDEPinf_CGatherDao.cpp IDEPinf_CLogDao.cpp IDEPinf_FuncDef.cpp IDEPinf_main.cpp msg_tool.cpp OcciDataBase.cpp
正常顺序:
SRCS=CException.cpp comm_tool.cpp IDEPinf_CommTool.cpp IDEPinf_CGatherDao.cpp IDEPinf_main.cpp msg_tool.cpp OcciDataBase.cpp IDEPinf_CMainBusinessProcess.cpp IDEPinf_CBizFileCheck.cpp IDEPinf_CLogDao.cpp IDEPinf_CBizFindDupBill.cpp IDEPinf_CFileDao.cpp IDEPinf_FuncDef.cpp IDEPinf_CBizGather.cpp
阅读全文
0 0
- 结算采集程序IDEPinf,C++源文件编译顺序的问题
- VC中编译有C源文件的程序
- 编译 源文件奇怪的问题
- C语言源文件到汇编语言的编译
- [C++] 源文件编译过程
- 使用模块编译的方式编译多个.c源文件
- C语言中多个源文件编译
- c源文件到执行文件的编译过程
- c源文件到执行文件的编译过程
- 编译android源文件 odex问题
- Java源文件编译问题汇总
- gcc 编译顺序的问题
- gcc编译mex源文件遇到问题的解决
- C程序源文件注释格式
- C程序源文件注释格式
- C语言程序获取或者打印当前语句所在的行号、当前源文件的文件名、程序编译的日期等信息(__LINE__、__FUNCTION__、__FILE__、__DATE__、__TIME__)
- 再议编译系统的编译顺序问题
- 一个关于工资结算的小程序
- Deadlocked Schedulers 线程池等待故障排除
- 深度学习方法(五):卷积神经网络CNN经典模型整理Lenet,Alexnet,Googlenet,VGG,Deep Residual Learning
- Tablayout和ViewPager关联
- 统计学习方法(七)
- Python requests post提交数据
- 结算采集程序IDEPinf,C++源文件编译顺序的问题
- Ubuntu安装ssh PHP mysql Nginx
- Banner
- java.lang.NoSuchMethodException: com.onion.po.UserInfo.<init>()
- VMware虚拟磁盘编程指导(一)
- Spring Boot vs. Spring MVC vs. Spring: How Do They Compare? Spring, Spring Boot, Spring MVC, there a
- 先进的图表Web部件Nevron Chart for SharePoint发布v2016.1版本丨附下载
- 再出发
- 先码后看 spring aop切入点表达式 侵立删