Вопрос

Yesterday my friend and I set up our dev environments to begin working on a school assignment. Our professor gave us some assembly code to compile and link with our own C code to replace a linux booter program. However, for some reason the code will compile completely fine on my friends machine, but gives me a bunch of compiling errors. This code was given by the professor so I know it must be correct. We checked our bcc version and they are identical. Here is the error output:

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

This was generated using this shell script:

#!/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

And finally here is the main.c that it is compiling errors on:

/*******************************************************
*                  @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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top