为什么我在这里遭受循环依赖?(Why am I suffering Circular Dependency here?)
Utilities.h
#ifndef _UTILITIES_ #define _UTILITIES_ #include "MyFirstCairoPlugin.h" class PLUG_CLASS_NAME; class Utilities { private: PLUG_CLASS_NAME *pPlug; public: Utilities(PLUG_CLASS_NAME *plug); ~Utilities(); }; #endif // !_UTILITIES_
Utilities.cpp
#include "Utilities.h" Utilities::Utilities(PLUG_CLASS_NAME *plug) : pPlug(plug) { IColor color = IColor(100, 100, 100, 255); } Utilities::~Utilities() { }
这是我遇到麻烦的地方,使用
MyFirstCairoPlugin.h
这个classe:#ifndef _MYFIRSTCAIROPLUGIN_ #define _MYFIRSTCAIROPLUGIN_ #include "IPlug_include_in_plug_hdr.h" #include "resource.h" #include "Utilities.h" //class Utilities; class MyFirstCairoPlugin : public IPlug { private: public: Utilities *pUtilities; MyFirstCairoPlugin(IPlugInstanceInfo instanceInfo); ~MyFirstCairoPlugin(); }; #endif // !_MYFIRSTCAIROPLUGIN_
如果我不取消评论
//class Utilities;
(前向声明),它无法使用实用工具(即使我已将其包含在上面,使用#include "Utilities.h"
)。 它给了我“典型的”循环依赖性错误`:syntax error: missing ';' before '*' (compiling source file ..\..\..\IPlug_AddOns\Utilities.cpp)
我哪里错了?
Utilities.h
#ifndef _UTILITIES_ #define _UTILITIES_ #include "MyFirstCairoPlugin.h" class PLUG_CLASS_NAME; class Utilities { private: PLUG_CLASS_NAME *pPlug; public: Utilities(PLUG_CLASS_NAME *plug); ~Utilities(); }; #endif // !_UTILITIES_
Utilities.cpp
#include "Utilities.h" Utilities::Utilities(PLUG_CLASS_NAME *plug) : pPlug(plug) { IColor color = IColor(100, 100, 100, 255); } Utilities::~Utilities() { }
And this is where I've trouble, using this classe from
MyFirstCairoPlugin.h
:#ifndef _MYFIRSTCAIROPLUGIN_ #define _MYFIRSTCAIROPLUGIN_ #include "IPlug_include_in_plug_hdr.h" #include "resource.h" #include "Utilities.h" //class Utilities; class MyFirstCairoPlugin : public IPlug { private: public: Utilities *pUtilities; MyFirstCairoPlugin(IPlugInstanceInfo instanceInfo); ~MyFirstCairoPlugin(); }; #endif // !_MYFIRSTCAIROPLUGIN_
If I don't de-comment
//class Utilities;
(forward declaration), it is not able to use Utilities (even if I've included it above, with#include "Utilities.h"
). It gives to me the "typical" Circular Dependency error `:syntax error: missing ';' before '*' (compiling source file ..\..\..\IPlug_AddOns\Utilities.cpp)
Where am I wrong?
原文:https://stackoverflow.com/questions/40991478
更新时间:2023-07-18 07:07
最满意答案
所以这是我的答案:
$pid=0; $pid=$ssh->exec("(ps -ef | grep run.php | grep -v grep | awk '{print $2}')"); while ($pid >0) { echo "Process id when running=".$pid."\n"; $pid =$ssh->exec("(ps -ef | grep run.php | grep -v grep | awk '{print $2}')"); } echo "Process is not running \n";
说明:从Linux开始,输出将如下所示
bash-3.2$ ps -ef | grep run.php 506 1455 1 3 10:56 ? 00:00:02 /path/to/script/run.php
所以awk'{print $ 2}'将提供值1455,这是该过程的pid
So here is my answer:
$pid=0; $pid=$ssh->exec("(ps -ef | grep run.php | grep -v grep | awk '{print $2}')"); while ($pid >0) { echo "Process id when running=".$pid."\n"; $pid =$ssh->exec("(ps -ef | grep run.php | grep -v grep | awk '{print $2}')"); } echo "Process is not running \n";
Explanation: From Linux the output will be as bellow
bash-3.2$ ps -ef | grep run.php 506 1455 1 3 10:56 ? 00:00:02 /path/to/script/run.php
So awk '{print $2}' will provide value 1455 which is the pid of the process
相关问答
更多-
运行php输出作为shell脚本(run php output as shell script)[2023-10-25]
你可以管道( | )PHP的输出到sh执行: $ php -r 'echo "echo \$PATH";' | sh 输出: /选择/ local / bin目录中:/ opt / local / sbin中中:/ opt / local / bin目录中:/ opt / local / sbin中:/应用/甲基苯丙胺/库/斌:在/ usr / local / bin目录:在/ usr / bin中:/斌:/ usr / sbin目录:/ sbin目录 为简单起见,我使用-r读取了一些语句,但您可以通过将 ... -
为什么exec()和相关的函数调用不适合你。 您的虚拟主机没有安装PHP-CLI。 只是一个网络服务器模块 您需要使用PHP二进制文件的完整路径,因为缺乏合适的shell环境。 例如/usr/bin/php