我们有一个由VS构建的(纯本机C++).DLL.作为客户端,我们有一些本机C++应用程序和围绕这个用C++/CLI编写的DLL的.Net-Wrapper.最后,有一些用C#编写的.Net-Wrapper客户端应用程序.
我的问题是native.dll必须以与.Net世界不同的方式分发,并且VS不会跟踪该DLL.因此,要让我的所有C#应用程序正常工作,我必须将其复制到每个可执行文件目录中,或者将其放在%PATH%中(我会避免在开发人员计算机上,因为他们可能希望使用不同版本的DLL启动不同的应用程序).如果存在引用Wrapper-DLL的UserControl,则会出现更大的问题:您必须将DLL复制到VS的目录或再次复制到%PATH%.但最坏的情况发生在我们的翻译工具上.该工具跟踪.Net-Assemblies并将它们打包到可以发送给外部翻译器的Translator-packages中.据我所知,没有办法将原生.DLL放入该包中!
所以我打算将原生DLL静态链接到.Net-Wrapper,这将解决我的问题.但对于我们的Native应用程序,此本机DLL仍必须是DLL.
所以我有两个选择:
我有以下问题:
class Base
{
};
class Derived : public Base
{
};
class Different
{
};
class X
{
public:
template <typename T>
static const char *func(T *data)
{
// Do something generic...
return "Generic";
}
static const char *func(Base *data)
{
// Do something specific...
return "Specific";
}
};
Run Code Online (Sandbox Code Playgroud)
如果我现在这样做
Derived derived;
Different different;
std::cout << "Derived: " << X::func(&derived) << std::endl;
std::cout << "Different: " << X::func(&different) << std::endl;
Run Code Online (Sandbox Code Playgroud)
我明白了
Derived: Generic
Different: Generic
Run Code Online (Sandbox Code Playgroud)
但我想要的是,对于从Base派生的所有类,调用特定方法.所以结果应该是:
Derived: Specific
Different: …Run Code Online (Sandbox Code Playgroud) 是否有关于eclipse工作区文件(.location,x.tree,...)格式的(好)文档?
我需要这个以编程方式为自动构建创建工作区.不幸的是,我必须从.NET程序中完成这项工作,所以我不能使用任何Eclipse类来做到这一点!(我们使用Eclipse + CDT管理我们的Linux C++项目).
我刚刚意识到尝试通过decltype获取函数的返回类型不涉及VS2012上的ADL(参数依赖查找)(使用cl.exe V17.00.60610.1测试).
以下示例
#include <stdio.h>
#include <typeinfo>
namespace A {
int Func(void const *) {
printf("A::Func(void const *)\n");
return 0;
}
template <typename T> void Do(T const &t) {
Func(&t);
}
template <typename T> void PrintType(T const &t) {
printf("Type: %s\n", typeid(decltype(Func(&t))).name());
}
}
namespace B {
struct XX { };
float Func(XX const *) {
printf("B::Func(XX const *)\n");
return 0.0f;
}
}
int main(int argc, char **argv) {
B::XX xx;
A::Do(xx);
A::PrintType(xx);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
给
B::Func(XX const *) …Run Code Online (Sandbox Code Playgroud) c++ decltype argument-dependent-lookup c++11 visual-studio-2012
如何在gdb中的可变参数函数中看到参数包的值?
示例代码(VariadicDebug.cpp):
template <typename... Ts> int Do(int a, Ts... ts)
{
// Add breakpoint here. a can be seen using 'print a' but how to show ts???
return a;
}
int main(int argc, char **argv)
{
return Do(0, "Hello world!", 88.9);
}
Run Code Online (Sandbox Code Playgroud)
编译
g++ --std=c++11 -O0 -g VariadicDebug.cpp
Run Code Online (Sandbox Code Playgroud)
并运行gdb:
$ gdb ./a.exe
GNU gdb (GDB) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to …Run Code Online (Sandbox Code Playgroud)