问题标签 [unistd.h]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - unistd : 没有这样的文件或目录
我有以下test.cpp
文件:
我只想编译它,但我仍然有以下内容:
我unistd.h
在/usr/include/unistd.h
. 我的$LD_LIBRARY_PATH
环境变量是空的,所以我将它设置为/usr/include
(with export LD_LIBRARY_PATH=/usr/include
) 但问题仍然存在。我能做什么?
c - 在 Win10 的 CMake 中找不到
我正在为 renderdoc 使用 CMake GUI,我收到了这些消息。我应该如何修复它们?
c - C and write() function - File is being written in hexadecimal and written int value is not correct
I am trying to write into a file using the write()
function (included in <unistd.h>
). The program is simple: when running the executable, I type a message and then, the message and my user id (Linux UID) are saved into the file.
I was expecting that the following value could be saved into the file:
There are two problems:
- my file is being written in hexadecimal (when I open it using Sublime Text, all I can see are hexadecimal values)
- the integer inserted representing my user id is not correct
This is the result that I'm getting when running cat notes.txt
:
When I open the notes.txt file with Sublime Text, I can read the following data:
The first 4 bytes are not equal to "1000".
Why is my file being saved with hexadecimal values? And why is the number incorrect?
This is my source code:
I'm using an Ubuntu 14.04 Trusty Tahr (x64), and my GCC version is 4.8.4. Also, when compiling using the -Wall option, no warning is shown.
c - 适用于 Windows 的库“X11/Xlib.h”、“X11/Xutil.h”、“unistd.h”
我已经完成了一个 C 程序,它获取屏幕像素的 RGB 值(0-255),知道它的位置(x,y)。它适用于 Linux,但是当我尝试在 Visual Studio (Windows) 中编译它时,由于库 X11/Xlib.h、X11/Xutil.h、unistd.h 不存在而崩溃。
这是代码:
如何实现它以在 Windows 中运行?
c - Enforcing ending variadic function parameters with NULL
Is it possible to make declaration of variadic function so that it doesn't end with "..."?
Today I learned more about exec from unistd.h but through the day I've seen three (two actually) different declaration of execl:
1) int execl ( const char * path, const char * arg0, ..., (char*)NULL );
was shown to us in school and I imagined I would have to end the function call with a NULL value
2) int execl(const char *path, const char *arg, ... /* (char *) NULL */);
is what I've found in the exec(3) man page. That would probably mean I still have to end it with a NULL value, but it is not enforced.
3) int execl(const char *path, const char *arg, ...);
is what I found here. This one would probably normally put me to rest with the first one being a simplification for students, the second was a varning and this is the real thing (even though I would probably have normally higher regard for both options one and two.)
But then I found on the same site this declaration:
int execle(const char *path, const char *arg, ..., char * const envp[]);
Same question applies, I was unable to create variadic function not ending in ...
with gcc telling me that it's expecting ')' before ',' token
pointing to the comma after the three dots.
So finally, is it possible to make variadic functions ending with a NULL characters (execl) and if not, is it possible to make it end with predefined variable (execle)?
I tried to compile with gcc 6.3.1, I also tried --std=c11.
c - 如何暂停C程序?
固定的
我现在正在编写一个命令行工具并使用 C 语言,但我想知道如何暂停程序?(不中止它,但可以重新继续)我试图让它像“按 Enter 继续”。
我在Linux上所以我没有或者什么,我有,我尝试了“pause()”,但是这个功能无法实现“按Enter继续”,它不能重新继续。
想知道是否有一个功能或什么可以帮助我做到这一点?如果是,请告诉我,谢谢!
PS:这些是我上面的代码,如你所见,我正在使用一个名为“conti”的函数来设置暂停
加:忽略那些“延迟”功能,只是做测试。
c - 程序中的定时器太慢
您好,我正在创建一个 speedcube 计时器,我刚刚将时间居中,但后来我注意到它的时间太慢了,我尝试将 usleep 功能从 1000 更改为快或慢,有什么想法吗?
c++ - 有人遇到过在 Ubuntu 上找不到 unistd.h 的情况吗?
我正在努力寻找系统中的错误。它真的让我发疯。
系统:Ubuntu 16.04 LTS、gcc&g++ 4.9、5.3 5.4 可用。
本质上,我试图编译一些用于点云注册的代码,我没有更新我的机器,我开始看到 Boost 出于某种原因禁用了线程,产生了多个无法找到线程库的错误。我将所有内容回溯到查看 GLib 定义的 boost 标头的一部分,我检查了一下,似乎我的编译器在 gcc 或 g++ 中看不到 unistd.h。我检查了文件,一切都在那里,但实际上看不到。我尝试使用 -I 标志让编译器在目录中查找。
示例 c 代码。
如果我尝试使用命令编译g++ test_unistd.cpp -o main
,那么我得到
我能看到的所有文件都在那里,我似乎无法弄清楚问题所在。
mingw - 为什么 MSYS2 和 mingw-w64-x86_64-toolchain 中的 unistd.h 不同?
我正在运行推荐 MinGW 的 CLion。最新的似乎是 MSYS2。一开始CLion没有找到gcc、cmake等。为此,我必须安装 mingw-w64-x86_64-toolchain,它会在我的 msys64(MSYS2 安装文件夹)文件夹中创建一个 mingw64 文件夹。
我尝试编译的软件需要 MSVC 函数或 POSIX 函数,例如sysconf
. 但是sysconf是未定义的,至少在mingw-w64-x86_64-toolchain的unistd.h中是这样。在 MSYS2 本身的主要 unistd.h 中它是可用的。
那么,最大的区别是什么?为什么他们不一样?
c - 为什么我的代码以 exit code: 0 退出,即使循环条件仍然有效?
我正在尝试使用fork
withexecvp
同时运行两个 shell 命令。我有两个问题,当我输入时mkdir folder1&mkdir folder2
,它会创建一个名为的文件夹folder1
和另一个名为的文件夹folder2?
(问号包含在文件夹名称中)。另一个问题是代码在执行完这两个命令后就退出了。
这是代码:
更新 1:
我试图按照凯文的回答。我正在尝试同时执行多个进程,例如ps&ls&who&date
. 我尝试了一种递归方法,它给了我相同的行为。这是我的代码: