当使用G++ (例如Linux上的4.5版)时,有人能解释一下如果用户为C/C++混合系统写一个头文件会发生什么/可能发生什么吗?
#ifdef __cplusplus
extern "C" {
int myCPPfunc(some_arg_list....); /* a C++ function */
}
#endif
但在这里,myCPPfunc()是一个普通的C++函数,里面有一个def类--也就是说,它被错误地标记为C函数。
这会有什么影响?
我一直使用cgo来连接Go和C。然而,当我试图对Go和C++做同样的事情时,每次我试图调用一个函数时都会得到一个编译错误。使用代码目录中的go build .,我得到以下错误:
./main.go: In function 'void _cgo_3612c872201c_Cfunc_getint(void*)':
./main.go:48:53: error: invalid conversion from 'void*' to '_cgo_3612c872201c_Cfunc_getint(void*)::<anonymous struct>
所以我们写:
Customer c = new Customer();
为什么设计不像我们写的那样:
c = new Customer();
c.CreditLimit = 1000;
编译器可以计算出客户的c点,并允许在c上调用客户的成员?
我知道我们可能想写:
IPerson c = new Customer();
IPerson e = new Employee();
以便能够写:
public string GetName(IPerson object)
{
return object.Name
}
string name = GetName(c); // or GetNam
我对c是个新手,我已经学到了一些别人写的在windows上编译的源代码。
在linux上尝试编译后,我遇到了错误,因为linux不支持DWORD和UINT32。例如,我有6个文件。A.h,A.c,B.h,B.c,C.h,C.c.所有文件中都有这些关键字。
因此,我正在考虑两种可能的解决方案。定义和类型定义哪个更好。
1)
typedef unsigned long DWORD;
typedef unsigned short WORD;
typedef unsigned int UNINT32;
2)
#define DWORD unsigned long
#define WORD unsig
我使用a = 'linux!', b = 'linux!', c = 'linux', d='linux',为什么会发生这种情况?
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>