Menu

Help fixing errors in DEV compiler,

beho G.
2008-11-25
2012-09-26
  • beho G.

    beho G. - 2008-11-25

    I wrote the following program. but when I compile in Dev C++ 4.9.9.2
    //time.c

    include <stdio.h>

    include <dos.h>

    include <conio.h>

    include <bios.h>

    void interrupt (*oldTimer)();
    void interrupt newTimer();

    void main(){
    oldTimer = getvect(0x08);
    setvect(0x08, newTimer);
    keep(0, 1000);
    }
    void interrupt newTimer()
    {
    (*oldTimer)();
    }

    The following error occured.

    4 C:\Users\muhiuddin\Documents\time.c In file included from C:\Users\muhiuddin\Documents\time.c
    20 C:\Dev-Cpp\include\bios.h variable or field far' declared void 20 C:\Dev-Cpp\include\bios.h [Warning] no semicolon at end of struct or union 20 C:\Dev-Cpp\include\bios.h syntax error before '*' token 7 C:\Users\muhiuddin\Documents\time.c syntax error before '*' token 7 C:\Users\muhiuddin\Documents\time.cinterrupt' declared as function returning a function
    8 C:\Users\muhiuddin\Documents\time.c syntax error before "newTimer"
    8 C:\Users\muhiuddin\Documents\time.c [Warning] data definition has no type or storage class
    C:\Users\muhiuddin\Documents\time.c In function main': 11 C:\Users\muhiuddin\Documents\time.coldTimer' undeclared (first use in this function)
    (Each undeclared identifier is reported only once
    for each function it appears in.)
    10 C:\Users\muhiuddin\Documents\time.c [Warning] return type of 'main' is not int' At top level: 18 C:\Users\muhiuddin\Documents\time.c syntax error before &quot;newTimer&quot; C:\Users\muhiuddin\Documents\time.c In functionnewTimer':
    20 C:\Users\muhiuddin\Documents\time.c `oldTimer' undeclared (first use in this function)

    My Turbo C++ compiler is not running in windows vista 64 bit. Can anyone help me.

     
    • beho G.

      beho G. - 2008-11-26

      umm, thanks guys for your time

       
    • Wayne Keen

      Wayne Keen - 2008-11-25

      Is it just me, or are you trying to compile DOS code on an OS that has no DOS?

      You might be able to do something with djgpp, but I haven't used that in several years.

      Wayne

       
    • cpns

      cpns - 2008-11-25

      With respect, the errors are in your code not "in the DEV compiler".

      You have to realise that Windows is a multitasking operating systems and that processes share hardware resources. The timer is particularly important to the operation of the whole system, so you cannot simply hijack the timer interrupt and do what you will with it as you could in MS-DOS where only a single process was ever running. Apart from that the OS will not let you do so either.

      Even if you write 16 bit code (for which you'll need a different compiler), the interrupt will be virtualised and you may still not get precise timing.

      You appear to have added a bios.h file to the compiler's standard include file. Apart from being a bad idea to pollute the installation with foreign code, this header uses non-standard compiler extensions to support 16 bit x86 code that MinGW/GCC does not understand. Even if it worked, the header file does not contain the library object code - it is merely declarative, and you cannot link Turbo C++ libraries with MinGW/GCC!

      > My Turbo C++ compiler is not running in
      > windows vista 64 bit. Can anyone help me.

      Of course it does not. Win64 supports Win32 but not 16 bit (Win16 or MS-DOS code), that was finally dropped, because a) Win32 became mainstream in 1995, and b) anyone who has migrated to Win64 is unlikely to still have need for 16 bit code. Win64 is still not mainstream, and is normally an informed decision carefully considered, so you should have been aware of the restriction before you chose to use it perhaps.

      Why are you still trying to use an antique compiler?

      So your effort is doomed. Even if you got this 16 bit code to compile, it will not run on Win64.

      You do not need to do any of this, because unlike MS-DOS, Windows provides operating system services for most of the purposes you would ever want to do such a thing.

      Thake a step back and describe what it is you are actually trying to achieve, and perhaps a more modern and viable approach can be suggested.


      If you really want your Turbo C++ compiler to work (which is still the easiest way to get this antique code to compile), I suggest that you use a VM (using this: http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx - its free), and install either MS-DOS or Windows (Win16 or Win32), and run Turbo C++ in the VM.

      Clifford

      Clifford

       
      • Wayne Keen

        Wayne Keen - 2008-11-25

        djgpp used to have some hip fakes that would let it pretend it was running on a MS-DOS based system, but I don't know if that works with Vista. I will check later today if I have the time.

        Wayne

         
        • cpns

          cpns - 2008-11-25

          Since DJGPP requires DPMI I am pretty sure that it is a non starter in Win64.

          The think is if you want to build and run 16 bit applications (or even 32bit DOS-Extended applications), you would not choose to be running Win64.

          This is the 21st century after all!

           
          • Wayne Keen

            Wayne Keen - 2008-11-25

            You are right, this is one of those questions that is kind of strange.

            One would assume that if one were using code that relies on MS-DOS in this day and age,
            one would know how anachronistic such code is, and certainly would not blame a compiler
            for having problems with the code.

            Wayne

             

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.