0
請對這個碼一看: 「Hello World」 的Solaris對popen有問題嗎?
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
FILE *process_fp = popen("make -f -", "w");
if (process_fp == NULL) {
printf("[ERR] make not found!\n");
} else {
char txt[1024] = "all:\n\[email protected] Hello World!\n";
fwrite(txt, sizeof(char), strlen(txt), process_fp);
pclose(process_fp);
}
}
該程序將打印。它適用於Linux平臺,但在Solaris上失敗,它在此投訴:make: *** fopen (temporary file): No such file or directory. Stop.
。
我該如何解決這個問題?
只是一個相關說明,在操作系統或編譯器中發現一個錯誤是很少見的。所以當你從心態開始時,一定會有一些代碼出現問題。記住「Select is not broken」(來自「Pragmatic Programmer」的提示)。另見:http://www.travisswicegood.com/index.php/2009/01/04/select-isn-t-broken – sateesh 2009-12-09 09:22:05
對我來說,(opensolaris 2008.11在x86上)和Linux一樣工作 – Kimvais 2009-12-09 09:25:14
Works對於我在SPARC上的Solaris 10上,儘管編譯器正確指出您忘記了strlen()的#include。 你遇到什麼版本的Solaris? 在$ PATH中找到了什麼版本的make? (Solaris make或GNU make) –
alanc
2009-12-09 15:07:29