现在的位置: 首页 > 综合 > 正文

VS* 之VC 常见编译运行错误 积累

2013年10月13日 ⁄ 综合 ⁄ 共 1926字 ⁄ 字号 评论关闭

1.

#define LOG4CPLUS_STATIC      ->1

#include <log4cplus/logger.h>     ->2
#include <log4cplus/fileappender.h> 
#include <log4cplus/consoleappender.h> 
#include <log4cplus/layout.h>

注意,在改版本的时候有的时候会在不知不觉中搞乱了 ->1和->2的顺序,导致编译的错误。当心了。不然找了n久你都可能找不出答案。

 

2.

#include "stdstringt.h"

#import  "C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"  rename("EOF","rstEOF")

#import  "RedisCli.tlb" no_namespace
#include "global.h"
#include <string>
#include "Ado.h"
#include "WLock.h"
#include "RedisCliEx.h"
#include "HDTLog.h"

对于这个

#import  "C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"  rename("EOF","rstEOF")

一定要在 #include "Ado.h" 之前,因为不然就会ado.h找不到。

#include "stdstringt.h"

要放在

#include "global.h" 之前,因为 global.h中要用。

 

3.

#include <mbstring.h>

用于 ::_ws**

4.Init=?Init@@YGHXZ   @1 PRIVATE
 GetResult=?GetResult@@YGHHPADPAPAD@Z @2 PRIVATE
 SetResult=?SetResult@@YGHHPAD0@Z @3 PRIVATE

如果下面的两个找不到=后面的,可以先把第一个=后面的删掉。然后再看。

5.一个工程必须要要有一个 main函数,因为main函数要在函数 ___tmainCRTStartup 中被引用

6.The value of ESP was not properly saved across a function call

 

已知有一dll中有一函数返回值为整型数,参数为6个串,参数可在dll的函数中被改变,我使用如下语句调用该函数: 
typedef   int   (*TEST)(CString&,CString&,CString&,CString&,CString&,CString&); 
TEST   test; 
test=(TEST)GetProcAddress(hinst, "test "); 
test(a,b,c,d,e,f); 
运行时得到如下错误信息: 
The   value   of   ESP   was   not   properly   saved   across   a   function   call.     This   is   usually   a   result   of   calling   a   function   declared   with   one   calling   convention   with   a   function   pointer   declared   with   a   different   calling   convention.   
但是其他的程序(别人的程序)可以正常调用这个函数,请问这是为什么?

/////////////////////////////////////////

调用约定申明不一致

加   __stdcall调用约定

typedef   int   (_stdcall   *TEST)(CString&,CString&,CString&,CString&,CString&,CString&) ;

这种问题主要是调用约定不一致,别人在没有指明 WINAPI(__stdcall)的情况下,调用约定是 _cdecl

7.CoInitializeEx(NULL, COINIT_MULTITHREADED) ;进入COM的多线程房间

8._beginthreadex 需要加头文件 process.h

9.有的时候出现如下很奇怪的错误:1>PCL-pxi.lib(Dialog.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in CameraData.obj

可以看下是不是引用的lib库的Debug版和Release版不对头导致的。

10.当找不到系统的头文件时,检查下系统的查找路径。

抱歉!评论已关闭.