Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Cannot convert void(far interrupt *)(...) compiler error

dennisparkerdennisparker Member Posts: 478
I have a problem with some code. This code ran fine in a separate program that I had created with the .c extension. When I copied the code from that file, and pasted into the much larger program that I am modifying and that has a .cpp extension, I got the following error message:

"cannot convert void(far interrupt *)(...) to void(far interrupt *)()"

I went back to the original file and it compiles fine. I changed the name of the file from opto22.c to opto22.cpp and it generates the error above. Compiler is 16 bit Borland.

Here is the function stripped of the parts not pertaining to this question:


unsigned uApiInt; // defined globally

int check_for_opto( char *arg )
{
void (far __interrupt *lpIntApiV)();
char far *pId;
for (uApiInt = 0x20; uApiInt < 0x100; ++uApiInt)
{

// this is the line that triggers the error
lpIntApiV = _dos_getvect(uApiInt);
.
.
.
}
}

Any ideas?

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    :
    : Any ideas?
    :

    look at the function prototype in dos.h. I just tried it with VC++ 1.52C (also a 16-bit MS-DOS compiler) and had no problems in *.cpp filel

    [code]
    #include

    int main()
    {
    void (far __interrupt *lpIntApiV)();

    // this is the line that triggers the error
    lpIntApiV = _dos_getvect(0x21);

    return 0;
    }
    [/code]
  • dennisparkerdennisparker Member Posts: 478
    : :
    : : Any ideas?
    : :
    :
    : look at the function prototype in dos.h. I just tried it with VC++ 1.52C (also a 16-bit MS-DOS compiler) and had no problems in *.cpp filel
    :
    : [code]
    : #include
    :
    : int main()
    : {
    : void (far __interrupt *lpIntApiV)();
    :
    : // this is the line that triggers the error
    : lpIntApiV = _dos_getvect(0x21);
    :
    : return 0;
    : }
    : [/code]
    :

    It appears that the code you compiled is identical to the code that I am having trouble with.

    Do you have any thoughts on why the Borland compiler would compile the file with a .c extension but not with a .cpp extension?
  • stoberstober Member Posts: 9,765 ✭✭✭
    : Do you have any thoughts on why the Borland compiler would compile the file with a .c extension but not with a .cpp extension?
    :

    probably because the compiler uses stricter rules for c++ than for C. Again, you'll have to look at dos.h to see.
  • dennisparkerdennisparker Member Posts: 478
    : : Do you have any thoughts on why the Borland compiler would compile the file with a .c extension but not with a .cpp extension?
    : :
    :
    : probably because the compiler uses stricter rules for c++ than for C. Again, you'll have to look at dos.h to see.
    :

    I had looked at the prototype, but I am not savvy enough to figure out where I am going wrong. Here is the line from dos.h:

    void interrupt (__far * _RTLENTRY _dos_getvect(unsigned __interruptno))(...);

    From the Borland help file:

    _RTLENTRY Specifies the calling convention used by the Standard Run-time Library.

    Do you know the significance of the (...)?
  • stoberstober Member Posts: 9,765 ✭✭✭
    The elipses (...) means the function accepts a variable number of arguments. The function you are attempting to assign it takes no arguments. put the ... in the argument list of your function.

    [code]
    unsigned uApiInt; // defined globally

    int check_for_opto( char *arg )
    {
    void (far __interrupt *lpIntApiV)([red]...[/red]);
    char far *pId;
    for (uApiInt = 0x20; uApiInt < 0x100; ++uApiInt)
    {

    // this is the line that triggers the error
    lpIntApiV = _dos_getvect(uApiInt);
    .
    .
    .
    }
    }

    [/code]

  • dennisparkerdennisparker Member Posts: 478
    : The elipses (...) means the function accepts a variable number of arguments. The function you are attempting to assign it takes no arguments. put the ... in the argument list of your function.
    :
    : [code]
    : unsigned uApiInt; // defined globally
    :
    : int check_for_opto( char *arg )
    : {
    : void (far __interrupt *lpIntApiV)([red]...[/red]);
    : char far *pId;
    : for (uApiInt = 0x20; uApiInt < 0x100; ++uApiInt)
    : {
    :
    : // this is the line that triggers the error
    : lpIntApiV = _dos_getvect(uApiInt);
    : .
    : .
    : .
    : }
    : }
    :
    : [/code]
    :
    :

    I tried that and the error was changed slightly:

    original code && compiler error:

    void (far __interrupt *lpIntApiV)();
    "cannot convert void(far interrupt *)(...) to void(far interrupt *)()"


    new code && compiler error:

    void (far __interrupt *lpIntApiV)(...);
    "cannot convert void(far interrupt *)(...) to void(far*)(...)"

    In a pinch I suppose the obvious is to rename the file using the .c extension, but that would be a porting problem on its own. It is curious that the same compiler would not be backwardly compatible.
  • dennisparkerdennisparker Member Posts: 478
    : The elipses (...) means the function accepts a variable number of arguments. The function you are attempting to assign it takes no arguments. put the ... in the argument list of your function.
    :
    : [code]
    : unsigned uApiInt; // defined globally
    :
    : int check_for_opto( char *arg )
    : {
    : void (far __interrupt *lpIntApiV)([red]...[/red]);
    : char far *pId;
    : for (uApiInt = 0x20; uApiInt < 0x100; ++uApiInt)
    : {
    :
    : // this is the line that triggers the error
    : lpIntApiV = _dos_getvect(uApiInt);
    : .
    : .
    : .
    : }
    : }
    :
    : [/code]
    :
    :

    I finally got it to compile. Won't know for sure if it works because the system it is going in smoked on initial power up. When we get it back online I will know if the code works. The fix is:

    void far __interrupt (*lpIntApiV)(...);

    I found this construct in a sample bit of code in the help section of the Borland compiler (who would have thought to look in help :) ). Thanks.
  • Henri CaHenri Ca Member Posts: 1

    dennisparker

    I wonder why I am not able to resolve my issue using the same definition:

    void far __interrupt (*lpIntApiV)(...);

    Any suggestions?

    mine is like this:

    void (far interrupt *org_empcom_vector)(void);

Sign In or Register to comment.