C#项目中的文件有" 复制到输出目录"属性.但是在VC++项目中却没有.我知道,我可以在VC++中使用Build事件并在那里写一些类似的东西
xcopy /y /d %(FullPath) $(OutDir)
Run Code Online (Sandbox Code Playgroud)
有没有办法避免使用CMD(和其他脚本方法)?在这种情况下,msbuild可以帮忙吗?
我有一个库和一个使用库的控制台应用程序.该库有一个包含源文件和头文件的文件夹.
我的项目位于子/内部目录中,但我想要包含的库目录位于父/上层目录中.
我的项目目录:
H:\Gmail_04\gsasl-1.0\lib\libgsaslMain
Run Code Online (Sandbox Code Playgroud)
包含文件在这里:
H:\Gmail_04\gsasl-1.0\src
Run Code Online (Sandbox Code Playgroud)
如何使用相对于项目目录的路径,包含父/上层目录中的文件夹?
这行在小型测试程序中正常工作,但在我想要它的程序中,我得到以下编译器投诉:
#include <limits>
x = std::numeric_limits<int>::max();
c:\...\x.cpp(192) : warning C4003: not enough actual parameters for macro 'max'
c:\...\x.cpp(192) : error C2589: '(' : illegal token on right side of '::'
c:\...\x.cpp(192) : error C2059: syntax error : '::'
Run Code Online (Sandbox Code Playgroud)
我得到了相同的结果:
#include <limits>
using namespace std;
x = numeric_limits<int>::max();
Run Code Online (Sandbox Code Playgroud)
为什么它将max视为宏max(a,b); ?
有两个基类具有相同的函数名.我想继承它们,并以不同的方式搭乘每种方法.如何使用单独的声明和定义(而不是在类定义中定义)?
#include <cstdio>
class Interface1{
public:
virtual void Name() = 0;
};
class Interface2
{
public:
virtual void Name() = 0;
};
class RealClass: public Interface1, public Interface2
{
public:
virtual void Interface1::Name()
{
printf("Interface1 OK?\n");
}
virtual void Interface2::Name()
{
printf("Interface2 OK?\n");
}
};
int main()
{
Interface1 *p = new RealClass();
p->Name();
Interface2 *q = reinterpret_cast<RealClass*>(p);
q->Name();
}
Run Code Online (Sandbox Code Playgroud)
我没能在VC8中移出定义.我发现Microsoft特定关键字__interface可以成功完成这项工作,代码如下:
#include <cstdio>
__interface Interface1{
virtual void Name() = 0;
};
__interface Interface2
{
virtual void Name() = 0;
}; …Run Code Online (Sandbox Code Playgroud) 我在Visual Studio中编译了我的bison生成的文件并得到了以下错误:
...\_ position.hh(83):错误C2589:'(':'::'
...\_ position.hh(83)右侧的非法令牌:错误C2059:语法错误:'::'
. ..\_ position.hh(83):错误C2589:'(':'::'
...\_ position.hh(83)右侧的非法令牌:错误C2059:语法错误:'::'
相应的代码是:
inline void columns (int count = 1)
{
column = std::max (1u, column + count);
}
Run Code Online (Sandbox Code Playgroud)
我认为问题出在std :: max; 如果我将std :: max更改为等效代码,那么就没有问题了,但有没有更好的解决方案而不是更改生成的代码?
这是我写的野牛文件:
//
// bison.yy
//
%skeleton "lalr1.cc"
%require "2.4.2"
%defines
%define parser_class_name "cmd_parser"
%locations
%debug
%error-verbose
%code requires {
class ParserDriver;
}
%parse-param { ParserDriver& driver }
%lex-param { ParserDriver& driver }
%union {
struct ast *a;
double d;
struct symbol *s;
struct symlist *sl;
int …Run Code Online (Sandbox Code Playgroud) 是否有任何工具可以直接测试是否为32位或64位制作库?
在http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx上,VC++团队正式声明他们尚未实现C++ 11核心功能"Expression SFINAE".但是,从http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2634.html复制的以下代码示例将被VC++编译器接受.
例1:
template <int I> struct A {};
char xxx(int);
char xxx(float);
template <class T> A<sizeof(xxx((T)0))> f(T){}
int main()
{
f(1);
}
Run Code Online (Sandbox Code Playgroud)
例2:
struct X {};
struct Y
{
Y(X){}
};
template <class T> auto f(T t1, T t2) -> decltype(t1 + t2); // #1
X f(Y, Y); // #2
X x1, x2;
X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2
Run Code Online (Sandbox Code Playgroud)
我的问题是:什么是"表达SFINAE"?
我正在使用 Microsoft Visual C++ 将以下程序编译为 C++20 程序:
#include <iostream>
#include <tuple>
int main()
{
auto t1 = std::make_tuple("one", "two", "three");
auto t2 = std::make_tuple("one", "two", "three");
std::cout << "(t1 == t2) is " << std::boolalpha << (t1 == t2) << "\n";
std::cout << "(t1 != t2) is " << std::boolalpha << (t1 != t2) << "\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我看到以下输出:
(t1 == t2) is false
(t1 != t2) is true
Run Code Online (Sandbox Code Playgroud)
元组是相同的,那么为什么它的比较结果是错误的呢?我该如何解决?
如何让VS 2010一次运行多个C++编译过程?我的意思是并行构建对象模块; 我不想一次构建多个项目(我知道工具>选项>构建和运行<并行项目构建的最大数量,但这不符合我的要求).
基本上,我正在寻找Visual Studio相当于"make -jN".
我正在尝试开始进行单元测试.我下载了最新版本的gtest,并将其解压缩到A:\gtest指定的指令中,我打开了gtest.sln.如果我同意更新它,Visual Studio只允许我打开sln.然后,当我尝试构建时,我遇到了一堆错误:
1>------ Build started: Project: gtest, Configuration: Debug Win32 ------
1> gtest-all.cc
1>a:\gtest\include\gtest\gtest-printers.h(550): error C2977: 'std::tuple' : too many template arguments
1> b:\program files (x86)\microsoft visual studio 2012\vc\include\utility(73) : see declaration of 'std::tuple'
1>a:\gtest\include\gtest\gtest-printers.h(558): error C2977: 'std::tuple' : too many template arguments
1> b:\program files (x86)\microsoft visual studio 2012\vc\include\utility(73) : see declaration of 'std::tuple'
1>a:\gtest\include\gtest\internal\gtest-param-util-generated.h(4017): error C2977: 'std::tuple' : too many template arguments
1> b:\program files (x86)\microsoft visual studio 2012\vc\include\utility(73) : see declaration of 'std::tuple'
1> a:\gtest\include\gtest\internal\gtest-param-util-generated.h(4249) …Run Code Online (Sandbox Code Playgroud) visual-c++ ×10
c++ ×8
c++11 ×2
windows ×2
32bit-64bit ×1
bison ×1
c ×1
gcc ×1
googletest ×1
max ×1
msbuild ×1
sfinae ×1
templates ×1
tuples ×1