结算采集程序IDEPinf,C++源文件编译顺序的问题

结算采集程序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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值