我目前正在查看::delete用于删除指针的C++代码.
一个毫无意义的例子是:
void DoWork(ExampleClass* ptr)
{
::delete ptr;
}
Run Code Online (Sandbox Code Playgroud)
以这种方式使用delete关键字的目的是什么?
我需要帮助Unix.我试图看看两个语句(printf和fprintf)中的一个是否在文件中.我使用了命令:
search=`cat $file | grep -w "fprintf\|printf"`
Run Code Online (Sandbox Code Playgroud)
出于某种原因,它在文件中找不到这两者中的一个存在.为什么?
我有一个 Git 存储库,其中包含以下git log信息master:
commit 23c5565d156266f3e26943d0811abaa88f7957a1 (HEAD -> master)
Fourth commit.
commit 92c0d491c3fd537a06876d1c0fc69c27ebf3e935
Third commit.
commit 67d604623f1b7fd8492f42edd6aebda83b075173
Second commit.
commit 11ef1cc228c27c87771dbc1a6a3fa98b7a605fa5
First commit.
commit 946f4fb2a02042f450090414eee6324799eb35df
Initial commit
Run Code Online (Sandbox Code Playgroud)
使用libgit2我想执行变基,将前四个提交压缩在一起(23c556- 11ef1)并保持初始提交完好无损。我的目标是通过将master分支重新设置为 commit 946f4,选择第一个提交,然后压缩其他三个来解决这个问题。git rebase -i HEAD~4这与最近三个提交上的 squash 命令类似。
这是我为尝试解决此问题而编写的伪代码:
git_rebase_init( &rebase, m_repository, branch, nullptr, initialCommit, &opts );
bool shouldSquash = false;
git_oid rebaseOID = {{0}};
while ( git_rebase_next( &op, rebase ) == GIT_OK )
{
if ( shouldSquash …Run Code Online (Sandbox Code Playgroud) 我正在 Ubuntu 16.10 x64 上构建一个名为 using CMake 的简单 C++ Clang 工具程序ClangEx。
该项目有一个main.cpp文件。其内容如下:
#include "clang/Frontend/FrontendActions.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/CommandLine.h"
using namespace clang::tooling;
using namespace llvm;
static llvm::cl::OptionCategory MyToolCategory("my-tool options");
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
static cl::extrahelp MoreHelp("\nMore help text...");
int main(int argc, const char **argv) {
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
return Tool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>().get());
}
Run Code Online (Sandbox Code Playgroud)
它使用 CMake 成功构建,但当我使用它分析示例 C++ 程序时,出现以下错误:
$ ./ClangEx SandwichBar.cpp --
In file included from /home/bmuscede/SandwichBar.cpp:11:
In file included from /home/bmuscede/SandwichBar.h:14:
In file …Run Code Online (Sandbox Code Playgroud) 所以,我需要编写一个shell脚本,它接受一个文件路径作为参数,并在shell脚本中使用它.我知道我可以这样做:
$ ./script filename
Run Code Online (Sandbox Code Playgroud)
使用此解决方案,这将使我能够$1在shell脚本中使用此文件名字符串.
但是,我想知道是否可以使用输入重定向,所以我可以使用它传递文件名:
$ ./script < filename
Run Code Online (Sandbox Code Playgroud)
如果是这样,我将如何在shell脚本中访问此文件名?
我是shell脚本编码的新手,所以我不确定这是否可行.