小编Adr*_*ian的帖子

clang格式可以为单行if语句等添加大括号

是否有一个clang-format选项可以为所有if()/ do/while语句等添加大括号?

例如

if( i == 42 )
   std::cout << "You found the meaning of life\n";
else
   std::cout << "Wrong!\n";
Run Code Online (Sandbox Code Playgroud)

if( i == 42 )
{
   std::cout << "You found the meaning of life\n";
}
else
{
   std::cout << "Wrong!\n";
}
Run Code Online (Sandbox Code Playgroud)

运用

$ clang-format --version
clang-format version 3.6.0
Run Code Online (Sandbox Code Playgroud)

c++ clang clang-format

47
推荐指数
2
解决办法
7738
查看次数

docker容器中的gdb返回"ptrace:不允许操作".

我已经检查/proc/sys/kernel/yama/ptrace_scope了容器和主机 - 都将值报告为零但是当附加到pid时,一个gdb报告

Reading symbols from /opt/my-web-proxy/bin/my-web-proxy...done.
Attaching to program: /opt/my-web-proxy/bin/my-web-proxy, process 1
ptrace: Operation not permitted.
Run Code Online (Sandbox Code Playgroud)

我也尝试使用特权标志附加到容器

docker exec --privileged -it mywebproxy_my-proxy_1 /bin/bash
Run Code Online (Sandbox Code Playgroud)

主机操作系统是Fedora 25,其寄存器来自他们的存储库,容器是官方centos6.8

c++ gdb centos fedora docker

27
推荐指数
1
解决办法
1万
查看次数

使用clang编译时无法查看std :: string

g ++(GCC)5.2.0

clang版本3.7.1(标签/ RELEASE_371/final)

GNU gdb(GDB)7.12

由于某种原因,当使用clang编译时,Gdb无法找到std :: string的定义.我有自定义编译和构建gcc和clang,因为Centos 6.5附带了旧版本的gcc.

示例代码

#include <string>

int main()
{
    std::string s("This is a string");

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

用g ++编译和调试 - 工作得很好

[~]$ g++ -ggdb3 -std=c++14 stl.cpp 
[~]$ gdb a.out
GNU gdb (GDB) 7.12
Reading symbols from a.out...done.
(gdb) break main
Breakpoint 1 at 0x400841: file stl.cpp, line 5.
(gdb) r
Starting program: /home/vagrant/a.out 

Breakpoint 1, main () at stl.cpp:5
5       std::string s("This is a string");
(gdb) n
7       return 0;
(gdb) p s …
Run Code Online (Sandbox Code Playgroud)

gcc gdb clang++

9
推荐指数
4
解决办法
3670
查看次数

在Yii2中使用Gii从数据库视图创建CRUD

我已经使用mariadb视图的gii生成了一个模型,该模型起作用了。

然后尝试为模型使用gii CRUD生成器,我得到了错误

The table associated with app\models\Future must have primary key(s).
Run Code Online (Sandbox Code Playgroud)

这是完全可以理解的,因为视图没有PK。我发现一些建议说要向模型中添加primaryKey函数,所以我尝试了

public function primaryKey()
{
    return 'id';
}
Run Code Online (Sandbox Code Playgroud)

id是列名,实际上是基础表(它是视图的一部分)中的PK。但这失败了,但有例外

Cannot make static method yii\db\ActiveRecord::primaryKey() non static in class app\models\Future
Run Code Online (Sandbox Code Playgroud)

所以我尝试将方法设为静态,但随后引发新异常

Undefined index: i
1. in /home/adrian/projects/mtview/mtview/vendor/yiisoft/yii2-gii/generators/crud/Generator.php at line 509
Run Code Online (Sandbox Code Playgroud)

有没有解决的办法,还是现在无法使用gii为数据库视图生成代码?

php crud gii yii2

6
推荐指数
1
解决办法
2770
查看次数

Yii 2.0支持远程访问gii

简单的问题,试图在yii 2中启用远程访问gii - docs http://www.yiiframework.com/doc-2.0/guide-start-gii.html

Note: If you are accessing Gii from a machine other than localhost, the access will be denied by default for security purpose. You can configure Gii to add the allowed IP addresses as follows,

'gii' => [
    'class' => 'yii\gii\Module',
    'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
],
Run Code Online (Sandbox Code Playgroud)

事情是,它没有说明在哪里添加 - 猜猜配置/ web.php

但是在哪个部分?

yii2

5
推荐指数
1
解决办法
3792
查看次数

这是确保隐式类型转换不会发生的合法方法

这是否是确保隐式类型转换不会发生的合法方法?

#include <string>
#include <iostream>

void func(std::string s)
{
   std::cout << "Thanks for the string\n";
}
template<class T>
void func(T)=delete;

int main()
{
   func("test1");
// str.cc: In function ‘int main()’:
// str.cc:13:16: error: use of deleted function ‘void func(T) [with T = const char*]’
//     func("test1");
//     ^
//  str.cc:9:6: error: declared here
//  void func(T)=delete;
//       ^
//
   func(std::string("test2"));
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ c++11

4
推荐指数
1
解决办法
198
查看次数

使用Yii 2和PHP进入Web应用程序开发的第52页

你到了第52页,我正试图查看客户/添加路线.

我设法通过创建一个软链接修复它 - 但我为什么需要这是正确的方法来解决它或该书与yii代码库不同步

我检查了勘误并应用了建议的修复(以及示例下载书代码中的内容)

我知道书籍已经过时了 - 但这是我得到的错误

PHP User Error – yii\base\ErrorException

Exception 'yii\base\InvalidParamException' with message 'The file or directory to be published does not exist: /var/www/html/crmapp/vendor/bower/jquery/dist' 

in /var/www/html/crmapp/vendor/yiisoft/yii2/web/AssetManager.php:385
...
Run Code Online (Sandbox Code Playgroud)

现在bower目录不在我的机器上,即使我按照所有的作曲家指令安装到目前为止我的东西

[adrian@eagle:/var/www/html/crmapp]$ ls vendor/bower-asset/jquery/dist/
jquery.js  jquery.min.js  jquery.min.map
[adrian@eagle:/var/www/html/crmapp]$
Run Code Online (Sandbox Code Playgroud)

好的,我设法通过创建软链接来修复它

[adrian@eagle:/var/www/html/crmapp]$ ls -l vendor/
total 64
-rw-rw-r-- 1 adrian adrian  183 Jan  6 21:19 autoload.php
drwxrwxr-x 2 adrian adrian 4096 Jan  6 21:19 bin
lrwxrwxrwx 1 adrian adrian   12 Jan 12 19:28 bower -> bower-asset/
drwxrwxr-x 6 adrian adrian 4096 …
Run Code Online (Sandbox Code Playgroud)

php composer-php yii2

4
推荐指数
1
解决办法
1501
查看次数

通过composer安装yii2,它会一直提示输入密码

我只是按照yii网站的指示,并不真正了解作曲家.我按照http://www.yiiframework.com/doc-2.0/guide-start-installation.html上的说明进行操作

身份验证似乎正在运行,但它会一次又一次地提示我输入用户名/密码.

任何人都有一些东西我可以检查,看看为什么它一直提示?

[root@dndbox html]# composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
Installing yiisoft/yii2-app-basic (dev-master b528289495bf9721d2b8c628d69caad42e45b0ce)
  - Installing yiisoft/yii2-app-basic (dev-master master)
    Downloading: connection...
Could not fetch https://api.github.com/repos/yiisoft/yii2-app-basic/zipball/b528289495bf9721d2b8c628d69caad42e45b0ce, enter your GitHub credentials to go over the API rate limit
The credentials will be swapped for an OAuth token stored in /root/auth.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username: *.com
Password: 
An existing OAuth token for Composer is present and will …
Run Code Online (Sandbox Code Playgroud)

composer-php yii2

3
推荐指数
2
解决办法
1万
查看次数

clang-query和CXXMemberCallExpr匹配器

我试图找到如何使用CXXMemberCallExpr使用具有clang查询的匹配器

我已经尝试了各种情况排列,但无法让它发挥作用.看起来第一个char与转储相比较低,因此例如FunctionDecl在clang-query中变为functionDecl

如果-ast-dump匹配器名称与clang-query名称匹配会很好 - 但是猜测它们没有

例如.

clang-query> match CXXMemberCallExpr()
1:2: Matcher not found: CXXMemberCallExpr
clang-query> match cxxmemberCallExpr()
1:2: Matcher not found: cxxmemberCallExpr
clang-query> match CxxMemberCallExpr()
1:2: Matcher not found: CxxMemberCallExpr
clang-query> match CXXmemberCallExpr()
1:2: Matcher not found: CXXmemberCallExpr
clang-query> match cxxMemberCallExpr()
1:2: Matcher not found: cxxMemberCallExpr
Run Code Online (Sandbox Code Playgroud)

如果人们想要帮助更多我想创建一个匹配到Virtual :: foo(),所以所有调用基类的虚函数.

这是我试图使用的代码

class Virtual
{
   public:
      virtual void foo()
      {
      }
};

class Real : public Virtual
{
   public:
      virtual void foo()
      {
      }
};

void bar()
{
   Virtual *v=new Real();
   Real …
Run Code Online (Sandbox Code Playgroud)

c++ matcher clang abstract-syntax-tree

2
推荐指数
1
解决办法
1138
查看次数