小编gue*_*est的帖子

使用#ifndef #define #endif对C头文件进行最佳练习

关于以下"模式"的最佳实践是什么?

#ifndef BLAFOO_H
#define BLAFOO_H
/* ...
 * ...
 */
#endif /* BLAFOO_H */
Run Code Online (Sandbox Code Playgroud)

我应该如何命名#define指令中的标题?我已经看到了从说BLAFOO_H__BLAFOO_H_BLAFOO_H_等.

c coding-style header

13
推荐指数
3
解决办法
2万
查看次数

来自GCC内联汇编的系统调用

是否可以使用内联汇编块中的系统调用来编写单个字符?如果是这样,怎么样?它应该看起来像这样的"东西":

__asm__ __volatile__
                    (
                     " movl $1,  %%edx \n\t"
                     " movl $80, %%ecx \n\t"
                     " movl $0,  %%ebx \n\t"
                     " movl $4,  %%eax \n\t"
                     " int $0x80       \n\t"
                     ::: "%eax", "%ebx", "%ecx", "%edx"
                    );
Run Code Online (Sandbox Code Playgroud)

80美元是ascii中的'P',但是没有返回任何内容.

任何建议非常感谢!

c linux gcc system-calls inline-assembly

4
推荐指数
2
解决办法
3671
查看次数

标签 统计

c ×2

coding-style ×1

gcc ×1

header ×1

inline-assembly ×1

linux ×1

system-calls ×1