??xml version="1.0" encoding="utf-8" standalone="yes"?> 序用了很多的c++Ҏ的话,那么你必d很多工作了。像虚拟函数Q函数重载,l承Q默认值等{。具体如何{化,请参 boost.python的文档了?/p>
Traceback (most recent call last): 意思是说找不到dll。我把dll都copy到python/dlls下了q是不行Q而且我确定python的sys.path包含了python/dlls目录了?/p>
很是不解。网上也很难扑ֈ资料Qgoogle了很长时间找不到有用的资料,好像中文斚w的资料很的。今天尝试了一下google 英文资料Q终于有了新的发玎ͼ -- 有h到的问题跟我的是一L。后面那个Roman回答了一下,是文件扩展名的问题!Q!Z么不支持dll呢?不解。回去试 了一下把后缀名改了就成功了。。。why??? pyUtil的Win32 DLL工程Q除了pyUtil.cpp文g以外Q从工程中移除所有其它文Ӟq填入如下的代码Q? // pyUtil.cpp #include<windows.h> 在Python代码中调用这个动态链接库Q?(记得把dll的扩展名改ؓ.pydQ另外dll的\径要能够被检索到) 2、用boost.python库来构徏dll 的动态链接库Q只需把文件内Ҏ换ؓ下面的代码。当Ӟ~译需要boost_python.lib支持Q运行需要boost_python.dll支持 ? 可以非常明显地看刎ͼ用了boost.python库之后,单了很多。因为boost.pythonZ做了很多的事情。。恩?/p>
好像没有讲很多有用的东西Q光儡讲了Q呵c。。我也还在l学习之中。下ơ写点什么呢Ql学习了?/p>
试代码如下Q?br>
// volatile.cpp : Defines the entry point for the console application.
2//
3
4#include "stdafx.h"
5
6
7int _tmain(int argc, _TCHAR* argv[])
8{
9 //volatile int a = 1;
10 int a = 1;
11 printf ("a = %d\n", a);
12
13 __asm
14
{
15 mov DWORD ptr [ebp-4], 10h // 修改a的gؓ0x10
16 }
17
18 printf ("a = %d\n", a);
19
20 getchar();
21
22 return 0;
23}
24
25
如果~译器没有优化的话,打印出来的值应该是1?6。反之,如果没有使用volatileQ优化之后应该打印出来的??
我在vc6和vc2008下测试了一下:
-----------------------------------------------------------------------------------------
vc2008
-----------------------------------------------------------------------------------------
没有关键字volatile
debug下打印的?1 ?1 ---Z么会被优化了呢?我的优化~译选项是disabled?br>release下打印的?1 ?1
有关键字volatile
debug下打印的?1 ?1 --- 很奇怪!
release下打印的?1 ?16
我想可能是编译器对debug下作了特D处理。而且该程序非常简?/font>
vc6.0
-----------------------------------------------------------------------------------------
没有关键字volatile
debug下打印的?1 ?16
release下打印的?1 ?1
有关键字volatile
debug下打印的?1 ?16
release下打印的?1 ?1 --- 很奇怪!
结Q?br>在多U程多核的情况下Q要防止被编译器优化Q?/font>
]]>我这里只是简单的丢了?/pre>
2
3 #include "stdafx.h"
4 #include <windows.h>
5 #include <time.h>
6 #include <stdlib.h>
7
8 #define MAX_BUF_LEN 20 // buf len // 必须要大?
9 int nRead = 0; // read pos
10 int nWrite = 0; // write pos
11 int buf[MAX_BUF_LEN] = {0}; // loop buf
12
13 #define NN 20000
14 __int64 sum = 0;
15 __int64 lose = 0;
16 __int64 total = (__int64)(1+NN)*(__int64)NN/2;
17 bool bWriteFinished = false;
18
19 void WriteBuf(int n)
20 {
21 int rpos = nRead;
22 int wpos = nWrite;
23 wpos++;
24 // buf满(即write又追上了readQ? 注ؓ了避免与初始状态重复判?br> 25 // 所以这里最后一个buf没有写就认ؓ已经满了。所以MAX_BUF_LEN不能?
26 // q里Q直接丢弃该buf
27 if (wpos % MAX_BUF_LEN == rpos % MAX_BUF_LEN)
28 {
29 lose += n;
30 return;
31 }
32
33 buf[nWrite] = n;
34 nWrite++;
35 if (nWrite == MAX_BUF_LEN)
36 nWrite = 0;
37 }
38
39 int ReadBuf()
40 {
41 if (nWrite == nRead)
42 return -1;
43
44 int n = buf[nRead];
45 nRead++;
46 if (nRead == MAX_BUF_LEN)
47 nRead = 0;
48 return n;
49 }
50
51 DWORD WINAPI ReadThread(LPVOID lpParameter)
52 {
53 int tmp = 0;
54 int count = 0;
55 while (true)
56 {
57 //printf("ReadThread = %d\n", ReadBuf());
58 tmp = ReadBuf();
59 if (-1 != tmp)
60 {
61 count++;
62 sum += tmp;
63 if (count == NN)
64 {
65 printf ("ReadThread finished!\n");
66 break;
67 }
68 }
69 else if (bWriteFinished)
70 {
71 printf ("ReadThread finished222!\n");
72 break;
73 }
74
75 Sleep(rand() % 10);
76 }
77 return 0;
78 }
79
80 DWORD WINAPI WriteThread(LPVOID lpParameter)
81 {
82 int n = 0;
83 while (true)
84 {
85 n++;
86 WriteBuf(n);
87 if (n == NN)
88 {
89 printf ("WriteThread finished!\n");
90 bWriteFinished = true;
91 break;
92 }
93
94 Sleep(rand() % 10);
95 }
96 return 0;
97 }
98
99 int main(int argc, char* argv[])
100 {
101 srand(time(NULL));
102 // for (int i = 0; i < 10; i++)
103 // {
104 // printf ("rand = %d\n", rand() % 10);
105 // }
106
107 DWORD threadid[2] = {0};
108 HANDLE hThread[2] = {0};
109 int param = 0;
110 hThread[0] = CreateThread(NULL, 0, ReadThread, ¶m, CREATE_SUSPENDED, &threadid[0]);
111 ResumeThread(hThread[0]);
112 hThread[1] = CreateThread(NULL, 0, WriteThread, ¶m, CREATE_SUSPENDED, &threadid[1]);
113 ResumeThread(hThread[1]);
114
115 getchar();
116
117 printf ("total = %lld\n", total);
118 printf ("lose = %lld\n", lose);
119 printf ("sum = %lld\n", sum);
120
121 if (total == lose + sum)
122 {
123 printf ("loop buf works well!\n");
124 }
125 else
126 {
127 printf ("loop buf works wrong!\n");
128 }
129
130 return 0;
131 }
132 注意Q这里只允许一个线E读Q一个线E写。如果是多个U程d的话Q需要锁Q?/pre>
另外Q很多细节都没考虑q去
]]>
通过上一ơ的教程后,大家都应该会使用boost.python了。把c++E序~译成pyd文g。由于c++有很多特性,所以,如果你的E?/p>
q几天尝试着把c++E序库编译成python可调用的dllQ不知道Z么一直不可用。。很是郁闗老是昄如下的错误:
File "<pyshell#3>", line 1, in <module>
import pydll
ImportError: No module named pydll
http://mail.python.org/pipermail/c++-sig/2007-February/011971.html
You are using Python2.5. In this version of Python you have to have
file extension
to be "pyd" - sge.pyd
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
下面来看一下我的那个简单的例子Q?br>q个例子来自于网上,
http://www.vckbase.com/document/viewdoc/?id=1540
C++ 扩展和嵌?Python
作者:胡金?br>源码下蝲地址Q?a >http://www.vckbase.com/code/downcode.asp?id=2777
q是一个非常简单的dll工程。给python提供了一个函数static PyObject* Recognise(PyObject *self, PyObject *args)?/p>
1、不使用boost.python库来直接构徏dll
接下来,我们来用C++为Python~写扩展模块(动态链接库)Qƈ在PythonE序中调用C++开发的扩展功能函数。生成一个取名ؓ
#ifdef PYUTIL_EXPORTS
#define PYUTIL_API __declspec(dllexport)
#else
#define PYUTIL_API __declspec(dllimport)
#endif
#include<string>
#include<Python.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
std::string Recognise_Img(const std::string url)
{
//q回l果
return "从dll中返回的数据... : " +url;
}
static PyObject* Recognise(PyObject *self, PyObject *args)
{
const char *url;
std::string sts;
if (!PyArg_ParseTuple(args, "s", &url))
return NULL;
sts = Recognise_Img(url);
return Py_BuildValue("s", sts.c_str() );
}
static PyMethodDef AllMyMethods[] = {
{"Recognise", Recognise, METH_VARARGS},//暴露lPython的函?br> {NULL, NULL} /* Sentinel */
};
extern "C" PYUTIL_API void initpyUtil()
{
PyObject *m, *d;
m = Py_InitModule("pyUtil", AllMyMethods); //初始化本模块Qƈ暴露函数
d = PyModule_GetDict(m);
}
import pyUtil
result = pyUtil.Recognise("input url of specific data")
print "the result is: "+ result
用C++为Python写扩展时Q如果您愿意使用Boost.Python库的话,开发过E会变得更开心JQ要~写一个与上述pyUtil同样功能
#include<string>
#include <boost/python.hpp>
using namespace boost::python;
#pragma comment(lib, "boost_python.lib")
std::string strtmp;
char const* Recognise(const char* url)
{
strtmp ="从dll中返回的数据... : ";
strtmp+=url;
return strtmp.c_str();
}
BOOST_PYTHON_MODULE(pyUtil)
{
def("Recognise", Recognise);
}
]]>
有一D|间没写blog了。这几天都在研究怎么装c++Q让python可以用c++的库。在|上发现了boost.pythonq个好咚咚。不
q在使用q程中碰C炚w题。本文教大家如何?/p>
char const* greet()
{
return "hello, world";
}
装成python。实际上q是python教程里面的咚咚?/p>
首先下蝲BoostQ?a >www.boost.org。boost.python在boost里面了。在visual studio 2005 command prompt中navigation?/p>
boost\boost_1_34_0\下。记得一定要用visual studio 2005 command promptq个vs2005带的toolsQ不要用cmd.exeQ否则会
到很多错误的。然后就是把bjam.exe拯C个能被找到的目录下,或者直接也拯到boost\boost_1_34_0\下即可。然后,
讄python的根目录和python的版本,也可直接把它们加到坏境目录中Q那样就不用每次都设|一下?br>set PYTHON_ROOT=c:/python25
set PYTHON_VERSION=2.5
接着可以直接运行了Qbjam -sTOOLS=vc-8_0
整个~译q程要很长时间。。?/p>
成功之后Q就会有好多个boost_python-vc80-****.dll,.lib的,把他们都拯C个能被系l找到的目录Q不妨直接把他们?/p>
扔到c:\windows\system32下?/p>
接着Q我们开始编译hello。navigation到boost\boost_1_34_0\libs\python\example\tutorial下,bjam -sTOOLS=vc-8_0q行
Q在bin的目录下即会生成hello.pyd。这下就基本成功了,如果没成功的话,check一下上面boost_python的那些dll能否被系
l找到。另外,q里有python25的一个bug。。。我׃很长旉才在python的mail lists中找C。寒。。?/p>
错误如下所C:
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\tutorial>bjam
Jamroot:17: in modules.load
rule python-extension unknown in module Jamfile</D:/Learn/Python/boost/boost_1_3
4_0/libs/python/example/tutorial>.
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2/build\project.jam:312: in load
-jamfile
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2/build\project.jam:68: in load
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2/build\project.jam:170: in proj
ect.find
D:/Learn/Python/boost/boost_1_34_0/tools/build/v2\build-system.jam:237: in load
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\..\..\..\tools\build\v2/k
ernel\modules.jam:261: in import
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\..\..\..\tools\build\v2/k
ernel/bootstrap.jam:132: in boost-build
D:\Learn\Python\boost\boost_1_34_0\libs\python\example\boost-build.jam:7: in mod
ule scope
解决办法如下Q?br>在boost\boost_1_34_0\tools\build\v2\目录下找到user-config.jam文gQ打开?br>import toolset : using ;
下面加一行代码:
using python ;
再重新编译一下boostQ然后就没问题了。tutorial里面的hello能顺利编译通过。ps.q个问题困扰了我好长旉。。sigh。?/p>
?/p>
~译成功后会产生一个hello.pydQ在bin的目录下面?/p>
有好多办法测试此hello.pyd是否可以用?br>Ҏ一Q把它拷贝到python25\dlls下,打开IDLEQ?br>>>> import hello
>>> hello.greet()
'hello, world'
>>>
Ҏ二,直接在当前目录下写一个python文gQ然后直接调用hello.pyd卛_。MQhello.pyd是一个python文g了。。嗯
。操作hello.pyd根其他python文g是一L?br>q样成功了?/p>
如果到如下错误Q是因ؓpȝ找不到boost_python的dll。强烈徏议把他们都扔到system32下!?/p>
>>> import hello
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import hello
ImportError: DLL load failed: 找不到指定的模块?br>>>>
说明Qhello.cpp在boost\boost_1_34_0\libs\python\example\tutorial目录下。里面的内容是:
// Copyright Joel de Guzman 2002-2004. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
// Hello World Example from the tutorial
// [Joel de Guzman 10/9/2002]
char const* greet()
{
return "hello, world";
}
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(hello)
{
def("greet", greet);
}
其中
BOOST_PYTHON_MODULE(hello)
{
def("greet", greet);
}
是对greet从c++向python的一个封装声明吧Q装换就交给boost了?/p>
先写到这里了。下ơ再写。。嗯
1. 首先讲讲元组的操?br>׃参数是通过元组传进ȝQ所以我们不能老是通过Py_BuildValueq个函数来操作元l,那样太不方便了?br>Python提供了元l相关的操作Q下面这个例子演CZ如何操作。主要是下面几个函数Q?br>//new一个元l,传入size
pArgs = PyTuple_New(argc - 3);
//set元组的直Q第一个ؓ元组Q第二个为indexQ从0开始)Q第三个为value
PyTuple_SetItem(pArgs,0,Py_BuildValue("i",2000) );
PyTuple_SetItem(pArgs,1,Py_BuildValue("i",8) );
来自python doc的一个例?/p>
#include <Python.h>
int
main(int argc, char *argv[])
{
PyObject *pName, *pModule, *pDict, *pFunc;
PyObject *pArgs, *pValue;
int i;
if (argc < 3) {
fprintf(stderr,"Usage: call pythonfile funcname [args]\n");
return 1;
}
Py_Initialize();
pName = PyString_FromString(argv[1]);
/* Error checking of pName left out */
pModule = PyImport_Import(pName);
Py_DECREF(pName);
if (pModule != NULL) {
pFunc = PyObject_GetAttrString(pModule, argv[2]);
/* pFunc is a new reference */
if (pFunc && PyCallable_Check(pFunc)) {
pArgs = PyTuple_New(argc - 3);
for (i = 0; i < argc - 3; ++i) {
pValue = PyInt_FromLong(atoi(argv[i + 3]));
if (!pValue) {
Py_DECREF(pArgs);
Py_DECREF(pModule);
fprintf(stderr, "Cannot convert argument\n");
return 1;
}
/* pValue reference stolen here: */
PyTuple_SetItem(pArgs, i, pValue);
}
pValue = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
if (pValue != NULL) {
printf("Result of call: %ld\n", PyInt_AsLong(pValue));
Py_DECREF(pValue);
}
else {
Py_DECREF(pFunc);
Py_DECREF(pModule);
PyErr_Print();
fprintf(stderr,"Call failed\n");
return 1;
}
}
else {
if (PyErr_Occurred())
PyErr_Print();
fprintf(stderr, "Cannot find function \"%s\"\n", argv[2]);
}
Py_XDECREF(pFunc);
Py_DECREF(pModule);
}
else {
PyErr_Print();
fprintf(stderr, "Failed to load \"%s\"\n", argv[1]);
return 1;
}
Py_Finalize();
return 0;
}
2. class操作
把下面加入到test2.py中去。定义了一个很单的c,有一个name成员变量Q一个printName成员函数
class TestClass:
def __init__(self,name):
self.name = name
def printName(self):
print self.name
cpp文g
#include <python.h>
int main()
{
Py_Initialize();
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
PyObject * pArg = NULL;
PyObject * pClass = NULL;
PyObject * pObject = NULL;
pModule = PyImport_ImportModule("test2");
pClass = PyObject_GetAttrString(pModule, "TestClass");//得到那个c?br> pArg = PyTuple_New(1);
PyTuple_SetItem(pArg, 0, Py_BuildValue("s", "Jacky"));
pObject = PyEval_CallObject(pClass, pArg);//生成一个对象,或者叫作实?/p>
pFunc = PyObject_GetAttrString(pObject, "printName");//得到该实例的成员函数
PyEval_CallObject(pFunc, NULL);//执行该实例的成员函数
Py_Finalize();
return 0;
}
没有什么资料,先写到q里了。下面介l一下怎么build python25的源代码
3. ~译python源代?br>Z么要~译呢?因ؓ没有python25_d.libQ呵c顺便可以了解一下代码结构?br>解压~后Q有好多目录Q其中pcbuild和pcbuild8是我们要的。pcbuild对应着vc7.1?pcbuild8对应着vc8.0?br>因ؓ在用vc7.1Q也是2003了。所以我p说怎么?003来编译吧。事实上是从一位牛人那里学来的
http://blog.donews.com/lemur/archive/2005/12/17/660973.aspxQ那位大哥大概一q半前就在解剖python了,厉害
ѝ看来我只能后来居上了,娃哈哈。我按照他说的试了一下,~译成功Q?/p>
不过遇到一点小问题Q用vc2003打开那个solution的时候,发现作者没有把source code controlLQ郁P害的?/p>
们打开的时候一堆messagebox。不q不用管它就好了Q一直确定。最后试了一下那个python25_d.libQ没问题。不q记
得把python25_d.dll copyC个能被找到的目录Q比如说c:\windows\system32\下面。python25.dll也在q个目录?/p>
面。over。恩?/p>
python文g
#Filename test2.py
def Hello(s):
print "Hello, world!"
print s
cpp文g
#include <python.h>
int main()
{
Py_Initialize();
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
PyObject * pArg = NULL;
pModule = PyImport_ImportModule("test2");
pFunc = PyObject_GetAttrString(pModule, "Hello");
pArg = Py_BuildValue("(s)", "function with argument");
PyEval_CallObject(pFunc, pArg);
Py_Finalize();
return 0;
}
注意Q参数要以tuple元组形式传入。因个函数只要一个参敎ͼ所以我们直接?s)构造一个元l了?/p>
2. 一个有两个参数的例?/p>
python文g中加入以下代码,一个加函数
def Add(a, b):
print "a+b=", a+b
cpp文gQ只改了两行Q有注释的那两行
#include <python.h>
int main()
{
Py_Initialize();
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
PyObject * pArg = NULL;
pModule = PyImport_ImportModule("test2");
pFunc = PyObject_GetAttrString(pModule, "Add");//l于告别hello world了,开始用新的函?br> pArg = Py_BuildValue("(i,i)", 10, 15);//构造一个元l?/p>
PyEval_CallObject(pFunc, pArg);
Py_Finalize();
return 0;
}
其它的就cM了。。。基本上Q我们知道了怎么在c++中用python中的函数。接下来学习一下如何用python中的
class?/p>
附:Py_BuildValue的用例子,来自python documentationQ?/p>
Py_BuildValue("") None
Py_BuildValue("i", 123) 123
Py_BuildValue("iii", 123, 456, 789) (123, 456, 789)
Py_BuildValue("s", "hello") 'hello'
Py_BuildValue("ss", "hello", "world") ('hello', 'world')
Py_BuildValue("s#", "hello", 4) 'hell'
Py_BuildValue("()") ()
Py_BuildValue("(i)", 123) (123,)
Py_BuildValue("(ii)", 123, 456) (123, 456)
Py_BuildValue("(i,i)", 123, 456) (123, 456)
Py_BuildValue("[i,i]", 123, 456) [123, 456]
Py_BuildValue("{s:i,s:i}",
"abc", 123, "def", 456) {'abc': 123, 'def': 456}
Py_BuildValue("((ii)(ii)) (ii)",
1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))
0. 坏境讄
把python的include/libs目录分别加到vc的include/lib directories中去。另外,׃python没有提供debug libQ体地说Q就是没有提供python25_d.lib了。你可以自己~译python的源代码来得到python25_d.lib的,偶还没试q,呵呵。而且|上找了一下也没下载到。所以,如果你想要在debug下运行程序的话,你要把pyconfig.hQ在python25/include/目录下)的大概是?83行,把pragma comment(lib,"python25_d.lib")Ҏpragma comment(lib,"python25.lib")Q让python都用非debug lib.
1. 开始编E了
#include <python.h>
W一步就是包含python的头文g
2. 看一个很单的例子
1)python文gtest.pyQ很单的定义了一个函?/p>
#Filename test.py
def Hello():
print "Hello, world!"
q个应该能看懂的吧?否则的话Q回dl练python吧,呵呵。《简明Python教程》Swaroop, C. H. 著。沈z元 译?/p>
2)cpp文g
#include <python.h> //包含头文Ӟ在c++中嵌入pythonQ这是必ȝ
int main()
{
Py_Initialize();
PyObject * pModule = NULL;
PyObject * pFunc = NULL;
pModule = PyImport_ImportModule("test");
pFunc = PyObject_GetAttrString(pModule, "Hello");
PyEval_CallObject(pFunc, NULL);
Py_Finalize();
return 0;
}
W一步还是包含头文g
W二步,使用python之前Q要调用Py_Initialize();q个函数q行初始化?br>帮助文中如是说Q?br>The basic initialization function is Py_Initialize(). This initializes the table of loaded modules, and creates the fundamental modules __builtin__, __main__, sys, and exceptions. It also initializes the module search path (sys.path).
反正Q一开始你一定要调用?/p>
W三步,声明一些Python的变量,PyObjectcd的。其实声明也可放在前面,q个倒是无所谓的?/p>
W四步,import moduleQ也是你的脚本名字Q不需要加后缀名,否则会出错的?/p>
W五步,从你importq来的module中得C要的函数
pFunc = PyObject_GetAttrString(pModule, "Hello");
上面的例子已l够清楚的了Q最后一个是你要得到的函数的名字
W六步,调用PyEval_CallObject来执行你的函敎ͼW二个参Cؓ我们要调用的函数的函敎ͼ本例子不含参敎ͼ所以设|ؓNULL?/p>
W七步,调用Py_FinalizeQ这个根Py_Initialize相对应的。一个在最前面Q一个在最后面?/p>
W一ơ写教程。这个例子非常简单,本h也还在学习当中阿Q只能保证大家能够把q个例子q行h。徏议大家去看python的documentaionQ里面有讲怎么embedding python的。先写到q里Q其实目前也只学到这么多Q呵c下ơ学了更多以后再写。Over。恩?/p>
Z么要有这个关键字呢?因ؓ~译器在优化的时候,会把常用到的数据攑֜CPU的内部寄存器中。数据从寄存器中dQ远比从内存中读取要快!但是Q如果另一个线E改变了内存中的变量|那么此变量在寄存器中的值就q期了?/span>
/* Find the arch type */
#if defined(__x86_64__) || defined(_M_X64)
#
说明?/span>
64
位的
#else
#
说明?/span>
32
位的
2?/span> 如何判断使用的是什么编译器
#if defined( _MSC_VER )
#
说明是微软的
vc
~译?/span>
#elif defined( __GNUC__ )
#
说明?/span>
GNU
?/span>
#elif defined( __BORLANDC__ )
#
说明?/span>
borland
?/span>