[英]NVCC is not working when Intel compiler and -std=c++11 flag are used
[英]getpid on linux while using -std=c++11 as compiler flag
我想在使用-std = c ++ 11標志時使用sys / types.h,unistd.h(C風格)標頭中的getpid
函數,但之后有:
“函數getpid無法解析”。
有某種解決方法或等效功能嗎?
@編輯:
我再檢查一次,這不是標記錯誤
head.h
#ifndef HEAD_H_
#define HEAD_H_
#include <sys/types.h>
#include <unistd.h>
void test();
#endif /* HEAD_H_ */
head.cpp
#include "head.h"
void test()
{
pid_t pid = getpid(); // Function 'getpid' could not be resolved
}
這很奇怪,因為我也在“干凈”項目上進行了測試,根本沒有問題。
main.cpp中
#include <sys/types.h>
#include <unistd.h>
int main()
{
pid_t pid = getpid();
return 0;
}
看來我無法從unisted獲得任何功能,因為
char* a_cwd = getcwd(NULL,0);
還沒有解決
#include <unistd.h>
#include <iostream>
int main()
{
std::cout << getpid() << std::endl;
return 0;
}
dgs@dhome:~/Develop/Test2$ g++ -std=c++11 getpid.cpp
dgs@dhome:~/Develop/Test2$ ./a.out
11980
dgs@dhome:~/Develop/Test2$ g++ --version
g++ (Debian 4.9.2-10) 4.9.2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.