Does Microsoft Windows SDK support function as parameters?

This is a discussion on Does Microsoft Windows SDK support function as parameters? within the Windows Programming forums, part of the Platform Specific Boards category; Hi everyone, I'm trying to compile a C++ function with Mex of Matlab working on windows. Matlab recognise Microsoft Windows ...

  1. #1
    Registered User
    Join Date
    Jul 2014
    Posts
    2

    [SOVLED] Does Microsoft Windows SDK support function as parameters?

    Hi everyone,
    I'm trying to compile a C++ function with Mex of Matlab working on windows. Matlab recognise Microsoft Windows SDK 7.1 as C/C++ compiler but gives me problem with a line of code of this form

    type funct1( ... , type (*funct2)( type, type), ... )

    In other words, I'm trying to pass a function as a variable to another function. Does someone know if Microsoft Windows SDK support function as parameters?
    Thanks
    Emanuele
    Last edited by Emanuele Mentil; 07-03-2014 at 02:22 PM.

  2. #2
    Registered User
    Join Date
    Jul 2014
    Posts
    2
    After various test I can confirm that Win SDK support that notation.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,456
    what's the error message that you receive? Are you sure that you're passing the right kind of function as a parameter? the signature has to match (same type and number of parameters) what the declaration says.

    for example:

    Code:
    void a(int) {  }
    void b(int, int) {  }
    
    void c(void (*func)(int)) {  }
    you couldn't pass b to c as a parameter, because it doesn't match the signature of the parameter that c declares.
    Code:
    namespace life
    {
        const bool change = true;
    }

  4. #4
    Registered User cstryx's Avatar
    Join Date
    Jan 2013
    Location
    Canada
    Posts
    52
    That's more of a C way of doing it IMO, why not utilize a functor? Or even a lambda? Sure, function pointers work in C++, but that doesn't necessarily mean they are the best option.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Microsoft C++ V10 and Windows 2000 OS
    By johnggold in forum C++ Programming
    Replies: 4
    Last Post: 02-15-2012, 04:17 PM
  2. Windows Kernel parameters
    By swaugh in forum Windows Programming
    Replies: 0
    Last Post: 07-13-2007, 01:18 AM
  3. Microsoft Windows Architecture
    By planet_abhi in forum Windows Programming
    Replies: 0
    Last Post: 04-30-2004, 08:47 AM
  4. Windows 98 support to continue.
    By adrianxw in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 01-17-2004, 08:31 AM
  5. windows.h without the mouse support
    By ()Q() in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2002, 07:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21