我有一个使用cmake的项目,一个目标设置为仅使用MSVC构建:
if (MSVC)
add_library(test SHARED source.cpp)
endif()
Run Code Online (Sandbox Code Playgroud)
现在另一个问题是这个目标只针对MSVC 32bit.那么如何检测到生成器是MSVC64并跳过此目标?
我从C#启动一个进程如下:
public bool Execute()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "the command";
startInfo.FileName = "C:\\MyApp.exe";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
Log.LogMessage("{0} {1}", startInfo.FileName, startInfo.Arguments);
using (Process myProcess = Process.Start(startInfo))
{
StringBuilder output = new StringBuilder();
myProcess.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e)
{
Log.LogMessage(Thread.CurrentThread.ManagedThreadId.ToString() + e.Data);
};
myProcess.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e)
{
Log.LogError(Thread.CurrentThread.ManagedThreadId.ToString() + " " + e.Data);
};
myProcess.BeginErrorReadLine();
myProcess.BeginOutputReadLine();
myProcess.WaitForExit();
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
但这有一个问题......如果有问题的应用程序按顺序写入std out和std err:
std out: msg 1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行curl来在我的脚本中上传文件,使用批处理是痛苦的,因为我需要进行字符串操作等所以我转向PowerShell.
但是我似乎无法使用powershell来执行Curl:
$hash = "test"
$fileToUpload = "hello world.txt"
$user = "user"
$password = "passy"
curl --ftp-create-dirs -T $fileToUpload -u ${user}:${pass} ftp://example.com/$hash/$fileToUpload
Run Code Online (Sandbox Code Playgroud)
这导致:
Invoke-WebRequest : Parameter cannot be processed because the parameter name 'T' is ambiguous. Possible matches include:
-TimeoutSec -TransferEncoding.
At line:5 char:24
+ curl --ftp-create-dirs -T $fileToUpload -u ${user}:${pass} ftp://example.com/$ha ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Run Code Online (Sandbox Code Playgroud)
Curl.exe在我的PATH中.
我有一个QStackedWidge内部的T QDockWidget-取决于哪个页面显示我想要显示/隐藏的关闭按钮QDockWidget.我可以通过使用来做到这一点QDockWidget::setFeatures().
然而,我面临的问题是如何捕获关闭按钮的信号,以便我可以更改停靠功能/设置堆叠的小部件页面索引.

我试图使用事件过滤器:
class EventFilter : public QObject
{
Q_OBJECT
public:
EventFilter( QObject* aParent );
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
EventFilter::EventFilter( QObject* aParent )
: QObject( aParent )
{
}
bool EventFilter::eventFilter( QObject *obj, QEvent *event )
{
if ( event->type() == QEvent::Close )
{
return true;
}
return QObject::eventFilter( obj, event );
}
Run Code Online (Sandbox Code Playgroud)
并安装如下:
EventFilter* filter = new EventFilter( this );
u->dockWidget_6->installEventFilter( filter );
Run Code Online (Sandbox Code Playgroud)
在我的构造函数中QMainWindow- 该eventFilter() …
我正在为一种简单的脚本语言编写一个反编译器.这就是我所做的:
基本块
创建了一个基本块的集合,如下所述:
http://www.backerstreet.com/decompiler/basic_blocks.php
控制流图,支配树和循环集
由此我可以创建控制流图.
http://www.backerstreet.com/decompiler/control_flow_graph.php
从CFG我创建了支配树,这反过来允许我在CFG中找到循环集,如下所述:
http://www.backerstreet.com/decompiler/loop_analysis.php
这是一张包含我目前所有数据的图片:

构造循环
我的下一步应该是:
http://www.backerstreet.com/decompiler/creating_statements.php
这就是我的问题所在,因为我完全陷入困境.在我给定的数据中,结构化循环算法将如何应用?我不明白为什么它首先尝试将所有内容组织为do while循环 - 在我的示例中,这意味着块3中的"temp5_14 = temp5_14 + 16"将始终至少执行一次,这不是原始代码所执行的操作一点都不
这怎么可能,以及将它从do-while转换为while循环的下一步如何实际工作?对于在块6中结束的循环3,这看起来应该是一段时间(true) - 但是当它的head块是if语句时,它如何与算法一起工作?
TL; DR - 有人请举例说明"结构化循环"算法是如何工作的.
当我尝试使用带有/std:c++latest标志的MSVC2015构建boost时出现错误:
boost\algorithm\string\detail\case_conv.hpp(33): error C2143: syntax error: missing ',' before '<'
Run Code Online (Sandbox Code Playgroud)
哪个指向:
// a tolower functor
template<typename CharT>
struct to_lowerF : public std::unary_function<CharT, CharT>
Run Code Online (Sandbox Code Playgroud)
现在这似乎是由于这里提到的N4190:https://www.visualstudio.com/en-us/news/releasenotes/vs2015-update3-vs
/ std:c ++ latest还控制删除以下旧功能:N4190"删除auto_ptr,random_shuffle()和旧东西",P0004R1"删除不推荐的Iostreams别名",LWG 2385"function :: assign allocator argument doesn" "有意义",以及各种非标准特性(std :: tr1命名空间,一些TR1专用机制和std :: identity结构).
使用时:
std::string a,b;
return boost::iequals(a,b);
Run Code Online (Sandbox Code Playgroud)
并使用boost::ilexicographical_compare.
它也在这里提到:
https://blogs.msdn.microsoft.com/vcblog/2015/06/19/c111417-features-in-vs-2015-rtm/
Run Code Online (Sandbox Code Playgroud)Stephan T. Lavavej - MSFT Azarien: Removing auto_ptr/etc. will have positive consequences. It will prevent new code from using outdated/complicated/unsafe机器,它将减少非专家用户之间的混淆.(例如,不必要的unary_function/binary_function继承是常见的,因为许多用户认为STL算法/容器需要这个,而实际上只有过时的适配器.)而auto_ptr特别不安全,因为它的变异"复制"构造函数默默地移动来自左撇子.
那么如何使用VC2015的/ std:c ++最新版进行编译?现在看来,boost不兼容C++ 17吗?
在以下代码中:
template<size_t N>
int b(int q, const std::array<int, N>& types)
{
int r = q;
for (int t : types)
{
r = r + t;
}
return r;
}
int main()
{
b<2>(9, { 2,3 });
}
Run Code Online (Sandbox Code Playgroud)
如何避免在调用 b 时为 N 指定 2?为什么不能自动推导出这种类型?没有它我得到错误:
“b”:找不到匹配的重载函数“int b(int,const std::array &)”:无法推导出“N”的模板参数
为什么这段代码不能编译,我该怎么做才能编译?
#include <iostream>
using namespace std;
enum class myEnum : unsigned int
{
bar = 3
};
int main() {
// your code goes here
unsigned int v = 2;
switch(v)
{
case 2:
break;
case myEnum::bar:
break;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
ideone:
prog.cpp: In function 'int main()':
prog.cpp:18:16: error: could not convert 'bar' from 'myEnum' to 'unsigned int'
case myEnum::bar:
Run Code Online (Sandbox Code Playgroud)
未能在GCC和Clang中建立,在MSVC 2013中有效.
我有一个相当复杂的QGraphicsView/Scene设置,其中我有复杂交互的项目.
因此,我想对此进行单元测试,以避免在现有功能中产生错误.对于一个测试,我希望:
这将允许我检查项目是否被选中,被移动了正确的数量,并被取消选中.
但是我发现在发送mouseMove事件后鼠标状态变为"已释放",这是我的代码:
QTest.mousePress(gv.viewport(), Qt.LeftButton, Qt.NoModifier, QPoint(80,80), 100)
QTest.mouseMove(gv.viewport(), QPoint(80,80), 200)
QTest.mouseMove(gv.viewport(), QPoint(90,80), 300)
QTest.mouseMove(gv.viewport(), QPoint(100,80), 400)
QTest.mouseRelease(gv.viewport(), Qt.LeftButton, Qt.NoModifier, QPoint(80,80), 900)
Run Code Online (Sandbox Code Playgroud)
其中gv是QGraphicsView.
问题似乎是由QGraphicsItem将mouseMove事件视为hoverMoveEvents - 它应该被视为mouseMoveEvent!
根据文件:
http://qt-project.org/doc/qt-4.8/qgraphicsitem.html#setAcceptHoverEvents
所以看起来这些模拟事件不会设置"鼠标抓取项"?
有关:
编辑:
TLDR; 为什么我的假鼠标事件没有设置当前的鼠标抓取项?这会导致QGraphicsItems获取mouseHover事件而不是mouseMove事件.
我想从移植到的MSBuild的cmake忍者基于/的承诺,一个巨大的C ++和C#代码库,忍者有多少比的MSBuild更好的并行性,当它涉及到建设本地代码。有没有人有这样做的真实世界经验?我想知道移植的成本是否真的值得。理想情况下在构建时间之前和之后:)
另外,忍者怎么可能比 msbuild 快得多?我认为即使 B 需要链接 A 的输出,它也必须并行构建项目 A 和 B 的对象文件?
c++ ×5
boost ×1
build ×1
c# ×1
c++11 ×1
c++14 ×1
c++17 ×1
cmake ×1
decompiler ×1
enum-class ×1
msbuild ×1
ninja ×1
powershell ×1
pyqt ×1
qdockwidget ×1
qt ×1
qt4 ×1
stderr ×1
stdout ×1
visual-c++ ×1