DLL导出标题
extern "C"
void _declspec(dllexport) __stdcall foo();
Run Code Online (Sandbox Code Playgroud)
.def文件
EXPORTS
foo @1
Run Code Online (Sandbox Code Playgroud)
当我通过64位构建配置构建dll时,我遇到了这个警告.
警告LNK4197:多次指定导出'foo'; 使用第一个规范
但是,如果我通过32位构建配置构建dll,则警告永远不会发生.
问题是什么?有什么不同.
在接口的dll头文件中,我们通常使用这个技术,
#ifdef EXPORT_DLL
#define BASICAPI _declspec(dllexport)
#else
#define BASICAPI _declspec(dllimport)
#endif //_EXPORT_DLL
Run Code Online (Sandbox Code Playgroud)
但是如果def文件也存在,我们总是会在构建64位dll时遇到警告.
那么,我们应该写这样的代码吗?
#ifdef EXPORT_DLL
#define BASICAPI
#else
#define BASICAPI _declspec(dllimport)
#endif //_EXPORT_DLL
Run Code Online (Sandbox Code Playgroud)
它运作良好.但这对我来说并不熟悉.
给我你的意见.
一位提问者指出
Raymond,我认为C++示例不正确,因为根据ISO C++ 2003 Standard(10-3,第168页)未定义派生类中基类子对象的位置,并且您假设基类子对象始终位于一开始.C语言中的C语言也没问题,所以我坚持下去.
雷蒙德回答说
[代码没有做出这个假设.这就是使用static_cast而不是reinterpret_cast的重要原因.试一试:向OVERLAPPED添加一个虚方法(所以vtable在前面)并观察编译器的作用.-Raymond]
读完他的评论后,我猜错了.在示例中使用static_cast很好,但是reinterpret_cast不是.因为reinterpret_cast不能转换为vtable.我理解得对吗?
虽然,如果我在那里使用C-Style演员(不是reinterpret_cast),它也会出错吗?
我重新阅读了更有效的C++演员解释,以了解这一点.但是没有答案.
int __cdecl ccall(int i)
{
wprintf(L"ccall(%d)", i);
return 0;
}
int __stdcall stdcall(int i)
{
wprintf(L"stdcall(%d)", i);
return 0;
}
int __cdecl wmain(int argc, wchar_t **argv)
{
std::function<int(int)> fnc = ccall;
std::function<int(int)> fnstd = stdcall;
fnc(10); // printed well
fnstd(100); // printed well
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我担心我怎么分配__stdcall function给std::function对象.但是没有任何指定调用约定,它看起来好像工作.怎么std::function知道调用约定是什么?
There is CreateHardLink function to create Hardlinks.(Since Win2000)
And there is CreateSymbolicLink function since Vista has been released.
But why isn't there a CreateJunction?
How does mklink make a junction?
And How do I write codes to make junction in my app?
我今天读到了VS.h中的sal.h.
我有点惊讶.
// This section contains the deprecated annotations
|------------|------------|---------|--------|----------|----------|---------------|
| Level | Usage | Size | Output | NullTerm | Optional | Parameters |
|------------|------------|---------|--------|----------|----------|---------------|
| <> | <> | <> | <> | _z | <> | <> |
| _deref | _in | _ecount | _full | _nz | _opt | (size) |
| _deref_opt | _out | _bcount | _part | | | (size,length) |
| | _inout | | | | | |
| | …Run Code Online (Sandbox Code Playgroud) std::vector<char> v;
v.push_back('a');
v.push_back('b');
v.push_back('c');
v.push_back('d');
v.push_back('e');
v.push_back('f');
char c[3] = { 'z', 'x', 'y' };
// Want to make abzxyf
//v.insert(v.begin() + 2, c, c + 3); // it doesn't work as I wanted.
// Yes it works. but if c is more bigger, it will be crash.
std::copy(c, c + 3, v.begin() + 2);
v.clear();
v.push_back('a');
v.push_back('b');
v.push_back('c');
v.push_back('d');
v.push_back('e');
v.push_back('f');
// If vector needs more memory, I'd let him grow automactically
// So I tried this.(expected abcdezxy) …Run Code Online (Sandbox Code Playgroud) 我想制作一个自定义消息框.我想要自定义的是按钮的文本.
MessageBoxW(
NULL,
L"Target folder already exists. Do you want to overwrite the folder?",
L"No title",
MB_YESNOCANCEL | MB_ICONQUESTION
);
Run Code Online (Sandbox Code Playgroud)
我想按钮文本只是改变到Overwrite,Skip,Cancel.
什么是最简单的方法?
我必须使其与Windows默认消息框具有相同的外观和感觉.
您可以在此链接中看到一个有趣的表格.http://norvig.com/21-days.html#answers
该表描述了
Mutex 从主内存中锁定/解锁25 nanosec
100 nanosec
纳秒?
我很惊讶因为mutex lock速度比fetch data from memory.如果是这样,到底mutex lock是做什么的?Mutex lock桌上的意思是什么?
它有魔力吗?
当我点击网页上的下载按钮时,会下载并安装Google Chrome.
它不使用ActiveX.它甚至不需要在Vista或更高版本中使用UAC窗口.
怎么可能?
请让我知道如何做到这一点.
我想让我的程序像这样.
windows ×6
c++ ×3
winapi ×2
annotations ×1
c++11 ×1
casting ×1
containers ×1
dll ×1
dllexport ×1
dllimport ×1
filesystems ×1
hook ×1
installation ×1
installer ×1
junction ×1
kernel ×1
locking ×1
mutex ×1
ntfs ×1
pointers ×1
static-cast ×1
stl ×1
subclass ×1
sysinternals ×1
visual-c++ ×1