#include<stdio.h>
#include<stdlib.h>
#define GREY 1
#define BLACK 0
#define WHITE 2
typedef struct node * graph;
typedef struct stack * snode;
graph cnode(int data); //cnode is to create a node for graph
void cgraph(void);
struct node {
int data, color;
struct node *LEFT, *RIGHT, *TOP, *DOWN;
};//this structure defines a node of the graph
struct stack {
struct stack *priv;
struct cgraph *graph_node;
};// this is to define a structure which should hold node of a structure
extern snode sroot; …Run Code Online (Sandbox Code Playgroud) 我在temp2.h中声明了一个变量i,它只
extern i; 包含一行上面的行,并创建了另一个文件temp3.c
#include<stdio.h>
#include<temp2.h>
int main ()
{
extern i;
i=6;
printf("The i is %d",i);
}
Run Code Online (Sandbox Code Playgroud)
当我在上面编译时,
cc -I ./ temp3.c 我得到了以下错误
/tmp/ccJcwZyy.o: In function `main':
temp3.c:(.text+0x6): undefined reference to `i'
temp3.c:(.text+0x10): undefined reference to `i'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我在上面的temp3.c中声明了extern,正如我在上面的文章中提到的那样,KR第33页说.我为temp3.c尝试了另一种方法,使用相同的头文件temp2.h
#include<stdio.h>
#include<temp2.h>
int main ()
{
i=6;
printf("The i is %d",i);
}
Run Code Online (Sandbox Code Playgroud)
并编译它 cc -I ./ temp3.c 并得到以下错误
/tmp/ccZZyGsL.o: In function `main':
temp3.c:(.text+0x6): undefined reference to `i'
temp3.c:(.text+0x10): undefined reference to `i'
collect2: ld returned …Run Code Online (Sandbox Code Playgroud) 我不清楚__attribute__在CI中使用关键字已经阅读了gcc的相关文档,但我仍然无法理解这一点.可以帮助理解一些.
在这个链接上,我遇到了
http://lxr.linux.no/#linux+v2.6.36/include/linux/pci.h#L299
整数声明
unsigned int is_added:1;我已经制作了C程序并声明了整数,但在上面我看到了使用
:那
是什么语法?
我制作了一个仍在开发中的程序.我没有故意在我的程序中声明main.因为我正在开发一个用于制作图形和其他算法的库,我将在我的程序中使用.在C中开发这样一个库的目的是解决书中给出的问题.算法Thomas H Coreman如果有人想看,这是代码.
#include<stdio.h>
#include<stdlib.h>
#define GREY 1
#define BLACK 0
#define WHITE 2
typedef struct node *graph;
graph cnode(int data); //cnode is to create a node for graph
void cgraph(void);
struct node {
int data, color;
struct node *LEFT, *RIGHT, *TOP, *DOWN;
};
graph root = NULL;
void cgraph(void)
{
int n, choice, dir, count;
choice = 1;
count = 1;
graph priv, temp;
printf("Printf we are making a graph the first is root node\n");
while (choice == 1) …Run Code Online (Sandbox Code Playgroud) 我想了解pci_resource_start函数的工作所以我通过cscope浏览代码并搜索字符串pci_resource_start并在pci.h中得到以下内容
#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
Run Code Online (Sandbox Code Playgroud)
我无法理解上面的宏是如何工作的.上面的宏如何在配置空间中获得适当的基址寄存器?
#include<stdio.h>
int main ()
{
printf("%#04x",50);
}
Run Code Online (Sandbox Code Playgroud)
有人向我展示了上面的代码,我无法理解它,因为我在C程序中使用过printf,但这是我第一次在生活中看到的那种用法.为什么上面的代码打印输出为
0x32
Run Code Online (Sandbox Code Playgroud)
有人可以给我一些链接或引用某些东西,以便我能更好地理解它.