Thread: No matching function call

  1. #1
    Registered User
    Join Date
    Jul 2015
    Posts
    17

    No matching function call

    Greetings,

    I am hoping to recieve feedback on the following error:

    no matching function for call to `CCtm::SetVect (int, void ()())'
    candidates are: CCtm::SetVect(BYTE, void *)


    I have the function SetVect() declared and i am sending the required variables.

    Here is a code snip:

    Code:
    CCtm::CCtm()
    {
        if(!c_iInitOk)
        {
            SetupBIUM(c_wTmcrInit);
           
            SetVect (CTM_IRQ_MCSM2,  IrqCtmMCSM2);
            SetVect (CTM_IRQ_DASM3,  IrqCtmDASM3);
    
    
    
    
        }
    }
    
    
    //--------------------- CCtm::SetVect-------------------------
    void CCtm::SetVect(BYTE channel,void *startAdr)
    {
        long *pointer;
        pointer  = (long *)(IRQ_VECTOR_TAB_PTR + c_byBaseVect + channel);
        *pointer = (long) startAdr;
    }
    Thanks for your time.
    Last edited by Jscott; 07-08-2015 at 12:43 PM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Take a close look at the actual arguments of the function calls and compare them to the types of the formal parameters of the function definition. Do they match? Recall that function pointers are not convertible to void*.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Beware that casting a function pointer's address (or even ANY pointer for that matter) to long may cause truncation. If it can be helped, ensure you are assigning to the same type (e.g. void*) instead of long.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    Hey laserlight,

    The parameters are as follows:

    #define CTM_IRQ_MCSM2 1
    #define
    CTM_IRQ_DASM3 2

    IrqCtmMCSM2 and IrqCtmDASM3 are actually meant to be interrupt functions.

    friend __attribute__((interrupt)) void IrqCtmMCSM2(void);
    friend __attribute__((interrupt)) void IrqCtmDASM3(void);

  5. #5
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    I do believe it is right. I might have messed it up with the attribute cast.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I repeat: function pointers are not convertible to void*.

    Look carefully at the error message:
    Code:
    no matching function for call to `CCtm::SetVect (int, void ()())'
    candidates are: CCtm::SetVect(BYTE, void *)
    You can see that void()() and void* do not match. int and BYTE probably do match.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I repeat: function pointers are not convertible to void*.
    O_o

    I know what you are saying, but I wanted to add that the reality is actually more problematic.

    You can force the conversion of a pointer to a function to a `void *`, but the conversion may result in a loss of the actual value.

    In other words, you can force a pointer to a function to a `void *`; you may not get the pointer to a function back when you try to reverse the process.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  8. #8
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    I have tried researching on possible solutions to change a void * to void()().

    I am just wondering how/why it would be possible in a microtec compiler vs the GNU compiler.

  9. #9
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I am just wondering how/why it would be possible in a microtec compiler vs the GNU compiler.
    O_o

    Much like the pirate's code, the standard is more what you'd call guidelines.

    Some compiler vendors will add extensions, and some programmers will use extensions.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  10. #10
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    Hey guys,

    Just wanted to say thanks for your time and help.

    Here is the solution that seemed to work (if you were curious):

    void CCtm::SetVect(BYTE channel, void (*startAdr)(void))

    -J

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: no matching function for call to
    By zaihan in forum C++ Programming
    Replies: 1
    Last Post: 01-25-2013, 11:40 PM
  2. No matching function for call to...
    By 20120903 in forum C Programming
    Replies: 13
    Last Post: 09-07-2012, 01:44 PM
  3. Replies: 8
    Last Post: 07-08-2011, 01:16 PM
  4. No Matching Function Call for Constructor
    By manasij7479 in forum C++ Programming
    Replies: 5
    Last Post: 02-07-2011, 03:29 PM
  5. no matching function for call to
    By f6ff in forum C++ Programming
    Replies: 4
    Last Post: 06-10-2006, 03:34 PM

Tags for this Thread