问题标签 [strerror]
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.
python - “str”对象没有属性
我正在尝试在 excel 中打开一列并将其单元格中的所有值移动到列表中。
在我运行之后,我得到了错误:
但我也已经导入了所有内容。
这是我导入的内容:
c - 将 Zed Shaw 的调试宏移植到 MSVC
当 Zed Shaw 的 C 书籍“Learn C the Hard Way”免费阅读时,我在他的网站上找到了他的调试宏。它最初是为 Linux 设计的,并且运行良好,已经使用了一段时间。
现在,我已经开始为 Windows 编写 C 代码并且我正在使用 Visual Studio。我想在我正在处理的项目中使用这些调试宏。
问题如下:假设我想使用检查宏来确保函数返回没有错误。
将使用的宏定义如下:
但是,我遇到的问题是 Visual Studio 标记strerror()
为已弃用并中止编译。我计划在项目中使用线程,所以如果可能的话,我不想走“忽略”路线。
我所做的是创建了一个clean_errno()
与宏执行相同操作的函数,但使用全局缓冲区变量并调用strerror_s()
复制到其中,然后返回指向log_err()
宏的指针。但是现在我必须:
- 要么为这个 3-liner 函数创建一个全新的头文件和 C 文件,我认为这很丰富
- 或者我只是在调试宏的头文件中声明和实现该函数,这根本不被认为是好的 C 实践,而且也很丑陋。
是否有任何其他我不知道的技巧/黑客可以为此提供优雅而简单的解决方案?
c - GNU strerror_r 缓冲区含义
这些buf
/buflen
参数是做什么用的?
空缓冲区就像一个魅力:
此外,这个缓冲区看起来像未使用:
linux - strerror_r 在不同平台上的兼容性
我正在尝试使用 strerror_r() 函数来获取与错误代码相对应的错误字符串,并且我的目标是 BSD 和 Linux 平台,但是 strerror_r() 的手册页说:
所以我不确定它在不同平台上的兼容性(XSI 合规性和 GNU 特定合规性),如果你能帮我告诉它在哪些平台上兼容,我将不胜感激?在哪些平台上我从上面得到了哪个版本?
c - 如何使用将错误处理导出到 C 中的函数
我正在检查用户在调用 main 时是否输入了正确数量和类型的 cmd 参数。
我认为编写一个打印出一些文本的函数是个好主意,这样我可以在检查NULL
指针时重用它。我包括<errno.h>
.
然后我写了一个函数来检查参数是否正确和充分。
当我在 main 中调用它并int argc
作为参数给出时,我得到了成功,即使除了启动程序之外err_cmd_handle()
我没有给出任何参数。为什么条件无法正确检查?
c++ - 重新定义预定义的 errno 错误消息 (E2BIG)
有没有办法重新定义errno
错误消息?例如,我正在使用E2BIG
并且我想更改它在遇到错误时显示的错误消息。
这些消息存储为int
,因此当我重新定义它时,只会让我更改它的整数值,这不是很有用。我想更改消息本身。
当前的错误信息是:
Arg 列表太长
但我试图改变它,说一些不同的东西。有没有办法做到这一点?
c++ - std::string constructor with lvalue throws with clang
I am making use of Matei David's handy C++ wrapper for zlib, but I get an error when compiling on macOs (clang-1100.0.33.
The problem is here:
(Which IIUC has nothing to do with zlib, just trying to report errors in a thread safe manner).
If I change to this:
My program compiles and runs fine.
I have two questions:
Why does clang not like the constructor
std::string tmp(p, std::strlen(p));
?The buffer was declared at the beginning of the function as length 80. Why are we even bothering to look up the length?
The answer to 2 may answer this, but is there something wrong with my version?
Thanks.
c - perror and strerror with close(2) involved
I have this code with close(2) implemented, as many of you know(including myself) this closes the standard error, but what are the main repercussions of closing it?
And why is "main: Success" printed? Shouldn't every directory have the "." dir that can be opened?
On the other hand
This doesn't print anything, any ideas why?
python - 嵌套列表的元素总和
我有一个名为 list_6 的嵌套列表:
[[-1, 1, -1, 1, -1, 1, 1, 0, -1, 0, -1, -1, 1, 1, 1, 0, 1, -1, -1, -1 , 1, 1, 1, 0, 0, -1, 0, 0, 0, 1, 0, -1, 1, 1, -1, 0, 0, 1, 1, -1, 0, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1],...]]
列表的每个元素都包含从 -1,1 开始的整数,并且元素的长度不等,列表中有 20 个元素
我想创建一个名为 list_7 的新列表,如下所示:
[[13],[4],[5],...]],使嵌套列表中的每个元素相加,并打印结果。我尝试使用 iter.zip_longest:
[sum(i) for i in itertools.zip_longest(*list_6, fillvalue=0)]
但我得到一个错误功能:
'str' 对象不可调用
c - strerror_r 示例
我是错误处理的新手;在我的代码中,我需要测试函数的返回值并在发生错误时打印错误描述。
为了保持代码线程安全,我必须使用 strerror_r,但我有一些难以使用的地方。在以下代码中,发生了错误编号 22(ret_setschedparam 为 22)。如何使用strerror_r打印错误号 22 的描述,即“无效参数” ?
我认为这个原型应该是我需要的正确 strerror_r :
编译器给了我一个错误:它说 strerror_r 的输出是一个 int,而不是一个 char。