非常具体的 C++ 编译语法错误,我无法找到解决方案:我对 C++ 相当陌生,并且阅读了作为参数传递的函数。编译错误对我来说没有意义,因为我一遍又一遍地阅读了代码。请帮忙。
编辑:我删除了 waitpid(pid_t,int,int) 并坚持使用 system() 命令。感谢大家的帮助。
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
int main(){
/* puts apt-get purge text into ~$ purge_e_output */
system("sudo apt-get purge enlightenment > purge_e_output.txt");
system("echo **Pid of apt-get**");
system("pidof apt-get");
try{
pid_t waitpid(pid_t getpid("apt-get"), int *statusPtr, int WUNTRACED);
} catch(...){}
system("echo **REMOVING ENGLIGHTENMENT**");
system("sudo apt-get purge enlightenment");
system("pidof apt-get");
try{
pid_t waitpid(pid_t getpid("apt-get"), int *statusPtr, int WUNTRACED);
} catch(...){}
/* puts apt-get autoremove text into ~$ autoremove_e_output */
system("sudo apt-get autoremove > autoremove_e_output.txt");
system("echo **Pid of apt-get**");
system("pidof apt-get");
try{
pid_t waitpid(pid_t getpid("apt-get"), int *statusPtr, int WUNTRACED);
} catch(...){}
system("echo **REMOVING E DATA**");
system("sudo apt-get autoremove");
system("echo **Pid of apt-get**");
system("pidof apt-get");
try{
pid_t waitpid(pid_t getpid("apt-get"), int *statusPtr, int WUNTRACED);
} catch(...){}
/* puts apt-get autoclean text into ~$ autoclean_e_output */
system("sudo apt-get autoclean > autoclean_e_output.txt");
system("echo **Pid of apt-get**");
system("pidof apt-get");
try{
pid_t waitpid(pid_t getpid("apt-get"), int *statusPtr, int WUNTRACED);
} catch(...){}
system("echo **CLEANING**");
system("sudo apt-get autoclean");
system("echo **Pid of apt-get**");
system("pidof apt-get");
try{
pid_t waitpid(pid_t getpid("apt-get"), int *statusPtr, int WUNTRACED);
} catch(...){}
/* reinstall englightenment */
system("echo **REINSTALLING**");
system("sudo apt-get install enlightenment");
system("echo **Pid of apt-get**");
system("pidof apt-get");
try{
pid_t waitpid(pid_t getpid("apt-get"), int *statusPtr, int WUNTRACED);
} catch(...){}
/* logs */
system("echo && echo Logs for wtf just happened:");
system("echo && echo ~$ purge_e_output.txt && echo ~$ autoremove_e_output.txt && echo ~$ autoclean_e_output.txt");
}
编译错误:
~$ g++ JIC.cpp -o JIC
JIC.cpp: In function ‘int main()’:
JIC.cpp:12: error: expected ‘,’ or ‘...’ before ‘(’ token
JIC.cpp:18: error: expected ‘,’ or ‘...’ before ‘(’ token
JIC.cpp:26: error: expected ‘,’ or ‘...’ before ‘(’ token
JIC.cpp:34: error: expected ‘,’ or ‘...’ before ‘(’ token
JIC.cpp:42: error: expected ‘,’ or ‘...’ before ‘(’ token
JIC.cpp:49: error: expected ‘,’ or ‘...’ before ‘(’ token
JIC.cpp:58: error: expected ‘,’ or ‘...’ before ‘(’ token