?
Solved

C2J (C to Java Converter) Compilation error

Posted on 2003-03-11
9
Medium Priority
?
752 Views
Last Modified: 2008-02-01
Greetings! We are having some problems with compiling a C code using C2J, a translator from C to Java. Our code includes the header file dos.h and during compilation, it returns the following errors:
    c:\lng\tc\dos.h(180)error:syntax error before '*'
    c:\lng\tc\dos.h(211)error:syntax error before '*'
    c:\lng\tc\dos.h(180)error:'interrupt' declared as a function returning a function

What should we do?

Thank You!
0
Comment
Question by:bebe03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 22

Expert Comment

by:grg99
ID: 8114247
Look at those lines in your dos.h file.  
here's probably some #define being used, such as _stdcall or _far, which has to be defined differently in your case.


BTW do you really expect to translate C to Java?
The languages are sooo different!
For example, is the translator smart enough to figure out how to convert all the typical string-munging that goes on in most C programs?


Regards,


grg99

0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8117412
I'm sure we can fix it for you if you send a part of your code, especially lines 179, 180, 210, 211.

Mayank.
0
 

Author Comment

by:bebe03
ID: 8128051
Here is the dos.h file from C. Isn't it that dos.h is the same for all? What I mean is, it is already defined and it shouldn't be modified. Anyway, I hope you'd still help us. Thanks!

/*      dos.h

      Defines structs, unions, macros, and functions for dealing
      with MSDOS and the Intel iAPX86 microprocessor family.

      Copyright (c) Borland International 1987,1988
      All Rights Reserved.
*/
#if __STDC__
#define _Cdecl
#else
#define _Cdecl      cdecl
#endif

#if     !defined(__DOS_DEF_)
#define __DOS_DEF_

/* Variables */
extern      int            _Cdecl _8087;
extern      int            _Cdecl _argc;
extern      char            **_Cdecl _argv;
extern      char            **_Cdecl  environ;
extern      int            _Cdecl _doserrno;
extern      unsigned      _Cdecl _heaplen;
extern      unsigned char      _Cdecl _osmajor;
extern      unsigned char      _Cdecl _osminor;
extern      unsigned       _Cdecl _psp;
extern      unsigned      _Cdecl _stklen;
extern      unsigned       _Cdecl _version;

#define FA_RDONLY      0x01            /* Read only attribute */
#define FA_HIDDEN      0x02            /* Hidden file */
#define FA_SYSTEM      0x04            /* System file */
#define FA_LABEL      0x08            /* Volume label */
#define FA_DIREC      0x10            /* Directory */
#define FA_ARCH            0x20            /* Archive */

#define NFDS      20                  /* Maximum number of fds */

struct      fcb      {
      char      fcb_drive;            /* 0 = default, 1 = A, 2 = B */
      char      fcb_name[8];            /* File name */
      char      fcb_ext[3];            /* File extension */
      short      fcb_curblk;            /* Current block number */
      short      fcb_recsize;            /* Logical record size in bytes */
      long      fcb_filsize;            /* File size in bytes */
      short      fcb_date;            /* Date file was last written */
      char      fcb_resv[10];            /* Reserved for DOS */
      char      fcb_currec;            /* Current record in block */
      long      fcb_random;            /* Random record number */
};

struct      xfcb      {
      char            xfcb_flag;      /* Contains 0xff to indicate xfcb */
      char            xfcb_resv[5];      /* Reserved for DOS */
      char            xfcb_attr;      /* Search attribute */
      struct      fcb      xfcb_fcb;      /* The standard fcb */
};

struct      country {
      int      co_date;
      char      co_curr[5];
      char      co_thsep[2];
      char      co_desep[2];
      char      co_dtsep[2];
      char      co_tmsep[2];
      char      co_currstyle;
      char      co_digits;
      char      co_time;
      long      co_case;
      char      co_dasep[2];
      char      co_fill[10];
};

struct      DOSERROR {
      int      exterror;
      char      class;
      char      action;
      char      locus;
};

struct      dfree      {
      unsigned df_avail;
      unsigned df_total;
      unsigned df_bsec;
      unsigned df_sclus;
};

struct      fatinfo {
      char      fi_sclus;
      char      fi_fatid;
      int      fi_nclus;
      int      fi_bysec;
};

struct      devhdr      {
      long            dh_next;      /* Next device pointer */
      short            dh_attr;      /* Attributes */
      unsigned short      dh_strat;      /* Driver strategy routine */
      unsigned short      dh_inter;      /* Driver interrupt routine */
      char            dh_name[8];      /* Device name */
};

struct      time      {
      unsigned char      ti_min;            /* Minutes */
      unsigned char      ti_hour;      /* Hours */
      unsigned char      ti_hund;      /* Hundredths of seconds */
      unsigned char      ti_sec;            /* Seconds */
};

struct      date      {
      int            da_year;      /* Year - 1980 */
      char            da_day;            /* Day of the month */
      char            da_mon;            /* Month (1 = Jan) */
};

struct WORDREGS {
      unsigned int      ax, bx, cx, dx, si, di, cflag, flags;
};

struct BYTEREGS {
      unsigned char      al, ah, bl, bh, cl, ch, dl, dh;
};

union      REGS      {
      struct      WORDREGS x;
      struct      BYTEREGS h;
};

struct      SREGS      {
      unsigned int      es;
      unsigned int      cs;
      unsigned int      ss;
      unsigned int      ds;
};

struct      REGPACK {
      unsigned      r_ax, r_bx, r_cx, r_dx;
      unsigned      r_bp, r_si, r_di, r_ds, r_es, r_flags;
};

#define FP_OFF(fp)      ((unsigned)(fp))
#define FP_SEG(fp)      ((unsigned)((unsigned long)(fp) >> 16))


typedef struct {
      char      drive;            /* do not change      */
      char      pattern [13];      /*  these fields,      */
      char      reserved [7];      /*   Microsoft reserved */
      char      attrib;
      short      time;
      short      date;
      long      size;
      char      nameZ [13];      /* result of the search, asciiz */
}      dosSearchInfo;      /* used with DOS functions 4E, 4F      */


int       _Cdecl absread      (int drive, int nsects, int lsect, void *buffer);
int       _Cdecl abswrite(int drive, int nsects, int lsect, void *buffer);
int       _Cdecl allocmem(unsigned size, unsigned *segp);
int       _Cdecl bdos      (int dosfun, unsigned dosdx, unsigned dosal);
int       _Cdecl bdosptr      (int dosfun, void *argument, unsigned dosal);
struct      country *_Cdecl country      (int xcode, struct country *cp);
void       _Cdecl ctrlbrk      (int _Cdecl (*handler)(void));
void       _Cdecl delay      (unsigned milliseconds);
void       _Cdecl disable      (void);
int       _Cdecl dosexterr      (struct DOSERROR *eblkp);
long       _Cdecl dostounix      (struct date *d, struct time *t);
void          __emit__();
void       _Cdecl enable      (void);
int       _Cdecl freemem      (unsigned segx);
int       _Cdecl getcbrk      (void);
void       _Cdecl getdate      (struct date *datep);
void       _Cdecl getdfree(unsigned char drive, struct dfree *dtable);
void       _Cdecl getfat      (unsigned char drive, struct fatinfo *dtable);
void       _Cdecl getfatd      (struct fatinfo *dtable);
unsigned _Cdecl getpsp      (void);
int       _Cdecl getswitchar      (void);
void       _Cdecl gettime      (struct time *timep);
void      interrupt       (* _Cdecl getvect(int interruptno)) ();                  /* this is line 180 */
int       _Cdecl getverify      (void);
void       _Cdecl harderr      (int _Cdecl (*handler)());
void       _Cdecl hardresume      (int axret);
void       _Cdecl hardretn(int retn);
int       _Cdecl inport      (int portid);
unsigned char      _Cdecl inportb(int portid);
int       _Cdecl int86      (int intno, union REGS *inregs, union REGS *outregs);
int       _Cdecl int86x      (int intno, union REGS *inregs, union REGS *outregs,
                   struct SREGS *segregs);
int       _Cdecl intdos      (union REGS *inregs, union REGS *outregs);
int       _Cdecl intdosx      (union REGS *inregs, union REGS *outregs,
                   struct SREGS *segregs);
void       _Cdecl intr      (int intno, struct REGPACK *preg);
void       _Cdecl keep      (unsigned char status, unsigned size);
void        _Cdecl nosound      (void);
void       _Cdecl outport      (int portid, int value);
void       _Cdecl outportb(int portid, unsigned char value);
char      *_Cdecl parsfnm      (const char *cmdline, struct fcb *fcb, int opt);
int       _Cdecl peek      (unsigned segment, unsigned offset);
char       _Cdecl peekb      (unsigned segment, unsigned offset);
void       _Cdecl poke      (unsigned segment, unsigned offset, int value);
void       _Cdecl pokeb      (unsigned segment, unsigned offset, char value);
int       _Cdecl randbrd      (struct fcb *fcb, int rcnt);
int       _Cdecl randbwr      (struct fcb *fcb, int rcnt);
void       _Cdecl segread      (struct SREGS *segp);
int       _Cdecl setblock(unsigned segx, unsigned newsize);
int       _Cdecl setcbrk      (int cbrkvalue);
void       _Cdecl setdate      (struct date *datep);
void       _Cdecl setswitchar      (char ch);
void       _Cdecl settime      (struct time *timep);
void       _Cdecl setvect      (int interruptno, void interrupt (*isr) ());      /* this is line 211 */
void       _Cdecl setverify      (int value);
void       _Cdecl sleep      (unsigned seconds);
void        _Cdecl sound      (unsigned frequency);
void       _Cdecl unixtodos      (long time, struct date *d, struct time *t);
int       _Cdecl      unlink      (const char *path);

      /* These are in-line functions.  These prototypes just clean up
         some syntax checks and code generation.
       */

void      _Cdecl      __cli__            (void);
void      _Cdecl      __sti__            (void);
unsigned char _Cdecl __inportb__(int portid);
void      _Cdecl      __outportb__      (int portid, unsigned char value);
void      _Cdecl      __int__            (int interruptnum);

#define disable()      __cli__()            /* Clear interrupt flag */
#define enable()      __sti__()            /* Set interrupt flag */
#define inportb(portid) __inportb__(portid)      /* Byte IN instruction */
#define outportb(portid, v) __outportb__(portid,v)/* Byte OUT instruction */
#define geninterrupt(i) __int__(i)            /* Interrupt instruction */

/* some other compilers use inp, outp for inportb, outportb */
#define inp(portid)      inportb(portid)
#define outp(portid,v)      outportb(portid,v)

#if !__STDC__
char far *cdecl getdta(void);
void        cdecl setdta(char far *dta);

#define MK_FP(seg,ofs)      ((void far *) \
                     (((unsigned long)(seg) << 16) | (unsigned)(ofs)))

#define poke(a,b,c)      (*((int  far*)MK_FP((a),(b))) = (int)(c))
#define pokeb(a,b,c)      (*((char far*)MK_FP((a),(b))) = (char)(c))
#define peek(a,b)      (*((int  far*)MK_FP((a),(b))))
#define peekb(a,b)      (*((char far*)MK_FP((a),(b))))
#endif

#endif
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Accepted Solution

by:
grg99 earned 150 total points
ID: 8130555
Aha, the word "interrupt" appears in both of those lines.

Apparently the compiler that supplied that dos.h file had an "interrupt" keyword, but the one you're compiling with does not.  

You could just temporarily add a line at the top of
dos.h:   #define  interrupt

This will cause "interrupt" to map to nothing, probably removing your compile errors.


Only problem, if  you're defining any interrupt handlers, this won't work.


The best solution would be to try reloading your C compiler, with its appropriate include files.


Regards,


grg99


0
 

Author Comment

by:bebe03
ID: 8140595
thanks! we shall try your suggestion.
we will let you know what happens.

thanks again.
0
 

Author Comment

by:bebe03
ID: 8154107
Hi! Thanks it removed the errors. But now we're having some problems with the ieee.h library. Here is a copy of that file:

#ifndef _IEEE_FP_H_
#define _IEEE_FP_H_

#include "_ansi.h"

#include <machine/ieeefp.h>

/* FIXME FIXME FIXME:
   Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
   except in libm/test.  If that is the case, please delete these from here.
   If that is not the case, please insert documentation here describing why
   they're needed.  */

#ifdef __IEEE_BIG_ENDIAN

typedef union
{
  double value;
  struct
  {
    unsigned int sign : 1;
    unsigned int exponent: 11;
    unsigned int fraction0:4;
    unsigned int fraction1:16;
    unsigned int fraction2:16;
    unsigned int fraction3:16;
   
  } number;
  struct
  {
    unsigned int sign : 1;
    unsigned int exponent: 11;
    unsigned int quiet:1;
    unsigned int function0:3;
    unsigned int function1:16;
    unsigned int function2:16;
    unsigned int function3:16;
  } nan;
  struct
  {
    unsigned long msw;
    unsigned long lsw;
  } parts;
    long aslong[2];
} __ieee_double_shape_type;

#endif

#ifdef __IEEE_LITTLE_ENDIAN

typedef union
{
  double value;
  struct
  {
#ifdef __SMALL_BITFIELDS
    unsigned int fraction3:16;
    unsigned int fraction2:16;
    unsigned int fraction1:16;
    unsigned int fraction0: 4;
#else
    unsigned int fraction1:32;
    unsigned int fraction0:20;
#endif
    unsigned int exponent :11;
    unsigned int sign     : 1;
  } number;
  struct
  {
#ifdef __SMALL_BITFIELDS
    unsigned int function3:16;
    unsigned int function2:16;
    unsigned int function1:16;
    unsigned int function0:3;
#else
    unsigned int function1:32;
    unsigned int function0:19;
#endif
    unsigned int quiet:1;
    unsigned int exponent: 11;
    unsigned int sign : 1;
  } nan;
  struct
  {
    unsigned long lsw;
    unsigned long msw;
  } parts;

  long aslong[2];

} __ieee_double_shape_type;

#endif

#ifdef __IEEE_BIG_ENDIAN

typedef union
{
  float value;
  struct
  {
    unsigned int sign : 1;
    unsigned int exponent: 8;
    unsigned int fraction0: 7;
    unsigned int fraction1: 16;
  } number;
  struct
  {
    unsigned int sign:1;
    unsigned int exponent:8;
    unsigned int quiet:1;
    unsigned int function0:6;
    unsigned int function1:16;
  } nan;
  long p1;
 
} __ieee_float_shape_type;

#endif

#ifdef __IEEE_LITTLE_ENDIAN

typedef union
{
  float value;
  struct
  {
    unsigned int fraction0: 7;
    unsigned int fraction1: 16;
    unsigned int exponent: 8;
    unsigned int sign : 1;
  } number;
  struct
  {
    unsigned int function1:16;
    unsigned int function0:6;
    unsigned int quiet:1;
    unsigned int exponent:8;
    unsigned int sign:1;
  } nan;
  long p1;
 
} __ieee_float_shape_type;

#endif





/* FLOATING ROUNDING */

typedef int fp_rnd;
#define FP_RN 0       /* Round to nearest             */
#define FP_RM 1            /* Round down                   */
#define FP_RP 2            /* Round up                   */
#define FP_RZ 3            /* Round to zero (trunate)       */

fp_rnd _EXFUN(fpgetround,(void));
fp_rnd _EXFUN(fpsetround, (fp_rnd));

/* EXCEPTIONS */

typedef int fp_except;
#define FP_X_INV 0x10      /* Invalid operation             */
#define FP_X_DX  0x80      /* Divide by zero            */
#define FP_X_OFL 0x04      /* Overflow exception            */
#define FP_X_UFL 0x02      /* Underflow exception            */
#define FP_X_IMP 0x01      /* imprecise exception            */

fp_except _EXFUN(fpgetmask,(void));
fp_except _EXFUN(fpsetmask,(fp_except));
fp_except _EXFUN(fpgetsticky,(void));
fp_except _EXFUN(fpsetsticky, (fp_except));

/* INTEGER ROUNDING */

typedef int fp_rdi;
#define FP_RDI_TOZ 0      /* Round to Zero             */
#define FP_RDI_RD  1      /* Follow float mode            */

fp_rdi _EXFUN(fpgetroundtoi,(void));
fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi));

int _EXFUN(isnan, (double));
int _EXFUN(isinf, (double));
int _EXFUN(finite, (double));



int _EXFUN(isnanf, (float));
int _EXFUN(isinff, (float));
int _EXFUN(finitef, (float));

#define __IEEE_DBL_EXPBIAS 1023
#define __IEEE_FLT_EXPBIAS 127

#define __IEEE_DBL_EXPLEN 11
#define __IEEE_FLT_EXPLEN 8


#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))

#define __IEEE_DBL_MAXPOWTWO      ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
#define __IEEE_FLT_MAXPOWTWO      ((float)(1L << (32-8) - 1))

#define __IEEE_DBL_NAN_EXP 0x7ff
#define __IEEE_FLT_NAN_EXP 0xff


#define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
               ((*(long *)&(x) & 0x007fffffL)!=0000000000L))

#define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
               ((*(long *)&(x) & 0x007fffffL)==0000000000L))

#define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))

#ifdef _DOUBLE_IS_32BITS
#undef __IEEE_DBL_EXPBIAS
#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS

#undef __IEEE_DBL_EXPLEN
#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN

#undef __IEEE_DBL_FRACLEN
#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN

#undef __IEEE_DBL_MAXPOWTWO
#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO

#undef __IEEE_DBL_NAN_EXP
#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP

#undef __ieee_double_shape_type
#define __ieee_double_shape_type __ieee_float_shape_type

#endif /* _DOUBLE_IS_32BITS */

#endif /* _IEEE_FP_H_ */


The error is: Syntax error before '('. (In lines 159, 160, 171, 172, 173, 174, 182, 183, 186, 187, 191, 192, 193,). All of these lines have the same error.

We can't fix this problem. Please help us. Thanks in advance! =)
0
 
LVL 22

Expert Comment

by:grg99
ID: 8154925
You don't have _EXFUN defined apparently.

It's in stdio.h, so try including
stdio.h before include ieee.

0
 

Author Comment

by:bebe03
ID: 8158769
oops, we made a mistake in our previous comment. the code we posted was the ieeefp.h file.

Where should we include stdio.h?  in which file?

thanks!
0
 
LVL 22

Expert Comment

by:grg99
ID: 8159115
YOu can include stdio in any file, just as long as it gets included before ieeefp.h


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question