问题标签 [c]

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.

0 投票
11 回答
1450 浏览

c - Is GCC broken when taking the address of an argument on ARM7TDMI?

My C code snippet takes the address of an argument and stores it in a volatile memory location (preprocessed code):

I used an SVN version of GCC for compiling this code. At the end of function foo I would expect to have the value 1 stored in the stack and, at 0x40000d4, an address pointing to that value. When I compile without optimizations using the flag -O0, I get the expected ARM7TMDI assembly output (commented for your convenience):

It clearly stores the argument first on the stack and from there stores it at 0x40000d4. When I compile with optimizations using -O1, I get something unexpected:

This time the argument is never stored on the stack even though something from the stack is still stored at 0x40000d4.

Is this just expected/undefined behaviour? Have I done something wrong or have I in fact found a Compiler Bug™?

0 投票
7 回答
829 浏览

c - 大多数 Pythonic 方式等效于:while ((x = next()) != END)

这个 C 结构最好的 Python 习语是什么?

我没有能力重新编码 next()。

更新:答案似乎是:

0 投票
15 回答
59825 浏览

c++ - Visual Studio 上的 C

我正在尝试学习 C。作为 C# 开发人员,我的 IDE 是 Visual Studio。我听说这是 C/C++ 开发的好环境。然而,似乎无论我尝试做什么小事,直觉都失败了。有人可以提供很好的资源来说明如何:

  • 在 Visual Studio 中学习 C 的来龙去脉
  • 推荐一个更好的 C IDE + 编译器

编辑:另见:https ://stackoverflow.com/questions/951516/a-good-c-ide

0 投票
7 回答
20912 浏览

c - 如何将字节数组移动 12 位

我想将字节数组的内容向左移动 12 位。

例如,从这个类型的数组开始uint8_t shift[10]

我想将它向左移动 12 位,结果是:

0 投票
1 回答
2355 浏览

c - 在 C 中获取当前进程的 CPU 使用率

在 Windows 上,我可以这样做:

我怎样才能在 *nix 上做同样的事情?

0 投票
3 回答
18986 浏览

c - 在C中更改当前进程的优先级

在 Windows 上,我可以这样做:

我怎样才能在 *nix 上做同样的事情?

0 投票
7 回答
9278 浏览

c - 如何获取临时文件的文件名以在 Linux 中使用?

假设我正在用 C 语言创建一个需要使用临时文件的程序。在 /tmp 中创建临时临时文件可能不是一个好主意。是否有函数或操作系统调用为我提供临时文件名,以便我可以开始写入和读取?

0 投票
3 回答
8795 浏览

c - 有 C 语言的 wxWidgets 框架吗?

我的理解是wxWidgets适用于多种编程语言(C++、Python、Perl 和 C#/.NET),但不包括 C。C 编程语言是否有类似的框架,或者这不是 C是用来?

0 投票
6 回答
29466 浏览

c - 什么是 C 中好的开源 B-tree 实现?

我正在寻找用 C 编写的 B 树库的精益且构建良好的开源实现。它需要在非 GPL 许可下才能用于商业应用程序。理想情况下,该库支持将 B-tree 索引存储/操作为磁盘文件,以便可以使用可配置(即:最小)RAM 占用空间构建大型树。

注意:由于似乎有些混淆,二叉树和 B-Tree不是一回事。

0 投票
6 回答
1633 浏览

c - 应该使用哪个 4.x 版本的 gcc?

我工作的产品组目前正在使用 gcc 3.4.6(我们知道它很古老)作为大型低级 c 代码库,并希望升级到更高版本。我们已经看到在我们测试过的所有硬件平台上测试不同版本的 gcc 4.x 的性能优势。然而,我们非常害怕 c 编译器的错误(从历史上看是有充分理由的),并且想知道是否有人知道我们应该升级到哪个版本。

人们是否将 4.3.2 用于大型代码库并觉得它运行良好?