小编Fre*_*red的帖子

错误:多重定义和首先在这里定义

我尝试包含几乎所有标题组合。尝试使用以下方法编译目标文件:

gcc database.c -c
gcc database.o user_interface.c -o database
Run Code Online (Sandbox Code Playgroud)

结果是:

/tmp/ccWfp2tS.o: In function `addRecord':
user_interface.c:(.text+0x4b9): multiple definition of `addRecord'
database.o:database.c:(.text+0x0): first defined here
/tmp/ccWfp2tS.o: In function `printAllRecords':
user_interface.c:(.text+0x54a): multiple definition of `printAllRecords'
database.o:database.c:(.text+0x1a): first defined here
/tmp/ccWfp2tS.o: In function `findRecord':
user_interface.c:(.text+0x590): multiple definition of `findRecord'
database.o:database.c:(.text+0x24): first defined here
/tmp/ccWfp2tS.o: In function `deleteRecord':
user_interface.c:(.text+0x5ed): multiple definition of `deleteRecord'
database.o:database.c:(.text+0x36): first defined here
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

用户界面.c

#include "record.h"

int debugmode; 

int main(int argc, char *argv[])
{ …
Run Code Online (Sandbox Code Playgroud)

c makefile

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

如何在 C 中打印 1 位(不仅仅是最低有效位)?

我正在开发一个发送 TCP 标头的程序(模拟 3 次握手)。我有一个变量,该变量包含数据偏移量(3 位)、保留值(4 位)和 9 个标志(9 位)。我正在使用按位运算来设置位。问题是如何打印每个位?

  1. 假设我存储从 2 到 4(从左到右)开始的数据偏移量:例如。0111000000000000

如何打印这 3 位?多变的:

u_int16_t reserved_ofs_flags;
Run Code Online (Sandbox Code Playgroud)

我发现这个问题类似,但答案只适用于最不重要的问题:如何打印一位?

c bit-manipulation

0
推荐指数
1
解决办法
310
查看次数

标签 统计

c ×2

bit-manipulation ×1

makefile ×1