编译 bcc 兼容性问题

标签 c compiler-errors turbo-c bcc-compiler

昨天,我和我的 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/

相关文章:

c - 为什么 mex.h 中有一些错误?

c++ - 为什么在 C++ 中,值为 65536 的整数变量的输出为 0 而 < 65536 给出一个负整数,而 > 65536 值给出一个正整数?

c++ - 为什么 turbo c wraparound signed integer overflow 每次虽然有符号整数溢出是未定义的?

php - php源代码中的similar_text

c - 使用子串来计算单词出现的次数

c - 如何检查命令行中是否有字符串

c++ - boost::variate_generator 语法错误

c++ - LNK2019未解析的外部符号。创建二叉树

haskell - "The type signature for ‘main’ 缺少伴随绑定(bind)是什么意思”?

c - 如何找到无符号长整型中的所有质因数?