- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我试图了解 C99 中存储类说明符的确切行为,但某些 GCC 行为似乎不符合规范,除非我误解了规范。来自 6.2.2 (2):
Within one translation unit, each declaration of an identifier with internal linkage denotes the same object or function.
但是,我使用以下程序测试了 GCC (powerpc-apple-darwin9-gcc-4.2.1):
#include <stdio.h>
static int f() {
static int x = 0;
return x++;
}
static int g() {
static int x = 0;
return x++;
}
int main(int argc, char *argv[]) {
printf("g() = %i\n", g());
printf("g() = %i\n", g());
printf("f() = %i\n", f());
printf("f() = %i\n", f());
return 0;
}
使用-std=c99
编译,打印如下:
g() = 0
g() = 1
f() = 0
f() = 1
如果我正确理解规范,它应该打印:
g() = 0
g() = 1
f() = 2
f() = 3
我理解为什么 GCC 会偏离此处的规范,我只是想知道是否对这种行为有更深入的解释。
最佳答案
6.2.2(6)中说:
The following identifiers have no linkage: [...] a block scope identifier for an object declared without the storage-class specifier extern.
静态变量是对象的 block 范围标识符,它们没有被声明为extern
。因此它们没有联系,特别是没有内部联系。
关于c - C : does GCC follow the C99 spec, 中的链接还是我不了解规范?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2159627/
我正在尝试创建一个类似 Twitter 的关注/关注系统。表格设计是这样的 - leader_id | following_id | is_mutual 1 |
尊敬的数据库专家/程序员: 我有一个mysql表,里面有用户信息,比如 id user_id name etc. 1 userA 2
我正在尝试设置我的 User GraphQL 模型以具有要查询的 followers 和 following 属性。但是,我无法在 Sequelize 中建立关系。我正在尝试使用 Follower 模
在我的网站上,我有一个类似 twitter 的概念,我有一个具有以下结构的用户连接表, ============================================= ==========
下面列出的区别是什么: 最佳答案 首先,你知道Meta Robots Tags吗?Meta Robots Tags 是告诉蜘蛛或爬虫要抓取或索引哪些页面。 跟随意味着:页面将被抓取。 No
我正在做一些项目,我在考虑关注者和像推特这样的关注系统。我在数据库中有成员表。我怎样才能做关注者系统。逻辑是什么?我做了类似的事情:我创建了名称跟随的新表,我有 3 行。这些行是 id、user_id
这是用于 C 代码检测。我正在尝试标记没有中断的 case 语句。当 break 语句之前有多行时,树的层次结构如下所示。这是 C 中的示例: switch (x) { case 1: i
大家好,我正在使用 MySQL 和 PHP 制作关注者/被关注系统,所以我想获取我关注的用户的所有视频并按 ID 描述排序。 数据库架构: 例如,如果我的 user_id = 1,并且如果我正在关注
我正在尝试根据#following #followers 找到一个计算推特用户“重要性”的方程式 我要考虑的事情: 1. #followers/#following越多,他越重要。 2. 在 20/2
这是我得到的错误 undefined method `followed_users?' for # 提取的源代码(大约第 3 行): 1: 2: 3: 4: 5: 6:
我有一个用户模型,可以创建关系以拥有关注者并关注其他人,我从 Rails 教程中学到的一切都非常有效。一件事是,我正在尝试通过添加能够看到其他人的关注者并能够拥有关注/关注按钮选项的选项来将其推进到下
我正在尝试通过 Twitter Javascript Api(请参阅 here )检查登录用户是否在 Twitter 上关注我。如果没有,我将显示一个关注按钮。现在我似乎无法找出命令 isFollow
我希望能够使用 iOS 5 的 Twitter API 将所有用户关注者和关注者用户名放入 NSDictionary... 不过我遇到了障碍。我不知道如何使用 Twitter API 来执行此操作..
希望在域之后但在其他任何内容之前获取值。 因此 URL 的示例是: www.domain.com/following#2 我只想从该 url 中获取后面的单词。 目前有这个可以重定向用户并在任何片段等
我有下表: 关系 id、follower_id、followee_id、状态 用户 id、姓名、电子邮件 我想查找正在关注或被特定用户关注的所有用户。 这是我到目前为止所拥有的,但速度非常慢: SEL
我是 state Management 的新手,正在使用 provider package 。产生这些类型的异常有多少种不同的原因,我该如何解决,此异常是在 didChangeDependencies
所以我在这里尝试制作一个类似 Instagram 的应用程序,但仅适用于汽车,我尝试单击“关注”和“关注者”来查看我关注的人和关注我的人,但我不确定为什么会有NPE吗... 我成功地可以关注用户,用户
我是 state Management 的新手,正在使用 provider package 。产生这些类型的异常有多少种不同的原因,我该如何解决,此异常是在 didChangeDependencies
我讨厌发布“这应该很容易,我错过了什么”问题,但是......这应该很容易,我错过了什么?我在这个测试代码上没有得到匹配,我不明白为什么。模式是(或应该是)“任何三个数字,后跟任何三个相同的数字,后跟
我正在研究 Chapter 11在 Hartl 的教程中,试图让用户 Controller 中的未登录用户访问关注者和关注页面通过。我遇到了一个错误,Rails 会提示未定义的 admin? 方法,尽
我是一名优秀的程序员,十分优秀!