creating a function prototype for a DLL entry point

Discussion in 'C++' started by Lynn McGuire, Jan 3, 2007.

  1. Lynn McGuire

    Lynn McGuire Guest

    I am creating a function prototype for a DLL entry point. I dynamically
    load the DLL at runtime and then map the entry points.

    typedef SP_STATUS SP_API (* myRNBOsproReadProc)
    ( SP_IN RBP_SPRO_APIPACKET packet,
    SP_IN RB_WORD address,
    SP_OUT RBP_WORD data );

    myRNBOsproReadProc myRNBOsproRead;

    This worked OK with Watcom C++. However, Visual C++ 2003 is
    giving me a weird error message:

    x.cpp(46): error C2059: syntax error : '('

    I removed the parenthesis and then Visual C++ gives me:

    x.cpp(49): error C2165: 'left-side modifier' : cannot modify pointers to data

    Does anyone understand what is going on here ?

    Thanks,
    Lynn McGuire
    Lynn McGuire, Jan 3, 2007
    #1
    1. Advertising

  2. Lynn McGuire

    mlimber Guest

    Lynn McGuire wrote:
    > I am creating a function prototype for a DLL entry point. I dynamically
    > load the DLL at runtime and then map the entry points.
    >
    > typedef SP_STATUS SP_API (* myRNBOsproReadProc)
    > ( SP_IN RBP_SPRO_APIPACKET packet,
    > SP_IN RB_WORD address,
    > SP_OUT RBP_WORD data );


    Depending on what your macros evaluate to, this may or may not be
    compiler-specific code.

    >
    > myRNBOsproReadProc myRNBOsproRead;
    >
    > This worked OK with Watcom C++. However, Visual C++ 2003 is
    > giving me a weird error message:
    >
    > x.cpp(46): error C2059: syntax error : '('
    >
    > I removed the parenthesis and then Visual C++ gives me:
    >
    > x.cpp(49): error C2165: 'left-side modifier' : cannot modify pointers to data
    >
    > Does anyone understand what is going on here ?


    No, mostly because we don't have sufficient information. See this FAQ
    on posting code that doesn't work correctly:

    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    You might also want to try a Microsoft-specific group (see the partial
    list in
    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.9).

    Cheers! --M
    mlimber, Jan 3, 2007
    #2
    1. Advertising

  3. Lynn McGuire

    Jim Langston Guest

    "Lynn McGuire" <> wrote in message
    news:...
    >I am creating a function prototype for a DLL entry point. I dynamically
    > load the DLL at runtime and then map the entry points.
    >
    > typedef SP_STATUS SP_API (* myRNBOsproReadProc)
    > ( SP_IN RBP_SPRO_APIPACKET packet,
    > SP_IN RB_WORD address,
    > SP_OUT RBP_WORD data );
    >
    > myRNBOsproReadProc myRNBOsproRead;
    >
    > This worked OK with Watcom C++. However, Visual C++ 2003 is
    > giving me a weird error message:
    >
    > x.cpp(46): error C2059: syntax error : '('


    In VC++ 2003 this usually means that the compiler didn't understand what
    went BEFORE the (. SP_STATUS or SP_API is likely undefined.

    > I removed the parenthesis and then Visual C++ gives me:
    >
    > x.cpp(49): error C2165: 'left-side modifier' : cannot modify
    > pointers to data
    >
    > Does anyone understand what is going on here ?
    >
    > Thanks,
    > Lynn McGuire
    >
    >
    Jim Langston, Jan 4, 2007
    #3
  4. Lynn McGuire

    Lynn McGuire Guest

    >> typedef SP_STATUS SP_API (* myRNBOsproReadProc)
    >> ( SP_IN RBP_SPRO_APIPACKET packet,
    >> SP_IN RB_WORD address,
    >> SP_OUT RBP_WORD data );


    > In VC++ 2003 this usually means that the compiler didn't understand what went BEFORE the (. SP_STATUS or SP_API is likely
    > undefined.


    I moved the SP_API inside the parenthesis and it worked. SP_API
    is defined as _stdcall. SP_STATUS is defined as unsigned short int.

    This was suggested to me on news://comp.os.ms-windows.programmer.win32 .

    Thanks,
    Lynn
    Lynn McGuire, Jan 4, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam Fields
    Replies:
    0
    Views:
    2,785
    Sam Fields
    Oct 22, 2004
  2. FFrozTT

    DLL Entry Point

    FFrozTT, Sep 5, 2007, in forum: C++
    Replies:
    3
    Views:
    1,350
    mike3
    Sep 5, 2007
  3. June Lee
    Replies:
    2
    Views:
    778
    Jim Cobban
    Apr 13, 2008
  4. Sam Fields
    Replies:
    0
    Views:
    153
    Sam Fields
    Oct 22, 2004
  5. Saraswati lakki
    Replies:
    0
    Views:
    1,277
    Saraswati lakki
    Jan 6, 2012
Loading...

Share This Page