Here is the code:
#include <QtCore/QCoreApplication>
#include <QProcess>
#include <QProcessEnvironment>
int main(int argc, char *argv[])
{
QProcessEnvironment env;
// Environment variables required by CGI apps
env.insert("QUERY_STRING", url.encodedQuery());
env.insert("REQUEST_URI", url.toString());
env.insert("REQUEST_METHOD", "GET");
env.insert("REMOTE_ADDR", pSocket->peerAddress().toString());
//==========
QProcess process;
process.setProcessEnvironment(env);
process.start("php-cgi",QProcess::ReadWrite);
process.write("<?php print_r($_GET); ?>");
process.closeWriteChannel();
process.waitForFinished();
qDebug(process.readAll().data());
return 0;
}
Qt Creator reports more than 14000 errors. Here is a small sample of them:
In file included from ../QProcess/main.cpp:2: ../QProcess/QProcess:1: error: stray ‘\177’ in program ../QProcess/QProcess:1: error: stray ‘\2’ in program ../QProcess/QProcess:1: error: stray ‘\1’ in program ../QProcess/QProcess:1: error: stray ‘\1’ in program In file included from ../QProcess/main.cpp:2: ../QProcess/QProcess:1:8: warning: null character(s) ignored ../QProcess/QProcess:1: error: stray ‘\2’ in program
Here is a simple example instance of this error. The contents of a file called new.cpp:
Now compile it:
No problem. Let’s compile it again:
OMG! Screen after screen of errors! Most of these errors look like this:
The problem is that the compiler is trying to use the new file in the current directory, as the C++ standard library
<new>; used by<iostream>. In fact any file in the current directory, named after a C++ standard library header, which is used in the code being compiled, will likely cause an error. That our problem file is an executable obfuscates the error messages.It doesn’t occur on all the gcc machines I’ve tried.
ppu32-g++4.1.1 on PS3 Cell Fedora Linux certainly chokes.