gpt4 book ai didi

编译 bcc 兼容性问题

转载 作者:太空宇宙 更新时间:2023-11-04 07:25:52 27 4
gpt4 key购买 nike

昨天,我和我的 friend 设置了我们的开发环境,开始处理一项学校作业。我们的教授给了我们一些汇编代码来编译和链接我们自己的 C 代码以替换 linux Bootstrap 。然而,出于某种原因,代码在我 friend 的机器上编译得很好,但给我带来了一堆编译错误。这个密码是教授给的所以我知道它一定是正确的。我们检查了我们的 bcc 版本,它们是相同的。这是错误输出:

comiling ......
main.c:17.5: error: need '{'
main.c:17.7: error: chars undeclared
main.c:19.12: error: illegal indirection
main.c:20.15: error: illegal indirection
main.c:25.4: error: bad expression
main.c:25.10: error: need ';'
main.c:25.15: error: blk undeclared
main.c:25.19: error: buf undeclared
main.c:25.3: error: need ';'
main.c:25.4: error: bad expression
main.c:25.7: error: need ';'
main.c:25.4: error: bad expression
main.c:30.4: error: bad expression
main.c:30.9: error: need ';'
main.c:30.10: error: temp undeclared
main.c:30.14: error: illegal indirection
main.c:33.1: error: need ';'
main.c:eof: error: need '}'
linking .......
ld86: cannot open input file main.o
check a.out size
ls: cannot access a.out: No such file or directory
dump a.out to a VIRTUAL FD
dd: opening ‘a.out’: No such file or directory

这是使用这个 shell 脚本生成的:

#!/bin/bash

echo comiling ......
as86 -o bs.o bs.s
bcc -c -ansi main.c

echo linking .......
ld86 -d bs.o main.o /usr/lib/bcc/libc.a
echo check a.out size
ls -l a.out

echo dump a.out to a VIRTUAL FD
dd if=a.out of=mtximage.bin bs=1024 count=1 conv=notrunc

最后是编译错误的 main.c:

/*******************************************************
* @main.c file *
*******************************************************/
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;

#include "ext2.h"
typedef struct ext2_group_desc GD;
typedef struct ext2_inode INODE;
typedef struct ext2_dir_entry_2 DIR;

#define BLK 1024

char buf1[BLK], buf2[BLK];

int prints(chars *s)
{
while(*s)
putc(*s++);


}

u16 getblk(u16 blk, char *buf)
{
readfd( blk/18, ((blk*2)%36)/18, ((blk*2)%36)%18, buf);
}

char temp[256];

main()
{
u16 i,iblk;
char c;
GD *gp;
INODE *ip;
DIR *dp;

prints("read decsriptor block #2 into buf1[]\n\r");
getblk(2, buf1);
gp = (GD *)buf1;
iblk = (u16)gp->bg_inode_table;
prints("inodes blk = "); putc(iblk + '0'); prints("\n\r");

getblk((u16)iblk, buf1); // read first inode block block
ip = (INODE *)buf1 + 1; // ip->root inode #2

prints("read 0th data block of root inode into buf2[ ]\n\r");

getblk((u16)ip->i_block[0], buf2);
dp = (DIR *)buf2; // buf2 contains DIR entries

while((char *)dp < &buf2[BLK]){



c = dp->name[dp->name_len];
dp->name[dp->name_len] = 0;
prints(dp->name); putc(' ');
dp->name[dp->name_len] = c;

dp = (DIR *)((char *)dp + dp->rec_len);
}

prints("\n\rgo?"); getc();
}

最佳答案

 int prints(chars *s)

^ looks bad

关于编译 bcc 兼容性问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18472533/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com