DLL and functions parameters...

This is a discussion on DLL and functions parameters... within the C++ Programming forums, part of the General Programming Boards category; Hello, I'm new to the use of DLLs and I have a doubt: how are function parameters coded in DLLs? ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    106

    DLL and functions parameters...

    Hello, I'm new to the use of DLLs and I have a doubt: how are function parameters coded in DLLs?
    For example, say we have a function:
    Code:
    typedef struct
    {
        int length;
        int *pBuffer;
    }Type1;
    
    typedef struct
    {
        char *string;
        int    strlen;
    }Type2;
    
    typedef Type2  *Type3;
    
    int f( Type1 a , Type2 b , Type3 c );
    Now, after compilation in DLL, I want to call the function, but I have different delcariations for types:
    Code:
    typedef struct
    {
        int length;
        int *pBuffer;
    }NewTypeName_t1;
    
    typedef struct
    {
        char *string;
        int    strlen;
    }NewTypeName_t2;
    
    typedef NewTypeName_t2  *NewTypeName_t3;
    so, types are corresponding in size but not in name. Can I use function with these new types? Or are type-names encoded into DLLs?
    I'm almost shure that it should be a normal compilation=>functions are recognized only by name and parameters sizes, but I want to be shure...

    Thank you very much for help and explanations.

    BrownB

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    if the structures are identical than all the calling function has to do is typecast them to the type the dll expects. This does not convert the structures from one type to another, it only tells the compiler that you know what you are doing and not complain that the types are different. If you don't know what you are doing, well ... umm ... you might be in big trouble here if the structures are not really the same.
    Code:
    // call function f
    
     f( (Type1*) a , (Type2*) b , (Type3*) c );

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You can do it - but you really shouldn't.

    Typically, the DLL would come with a header file that contains all type definitions. Just use those.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Correct.

    void *

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 03:20 AM
  2. DLL class member functions
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 07-11-2003, 07:59 AM
  3. Calling App Functions from DLL
    By johnnie2 in forum Windows Programming
    Replies: 3
    Last Post: 03-19-2003, 01:08 AM
  4. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 05:29 AM
  5. how to call a DLL functions in VC++
    By mjmariveles in forum Windows Programming
    Replies: 4
    Last Post: 07-08-2002, 09:57 PM

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