CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2008
    Posts
    27

    Shared Functions Declaration

    Good Morning!

    I have some code done in C. I'm building it using Visual C++, but there are some errors like:

    Error 1 error C2054: expected '(' to follow 'SHARED_FUNCTION'
    Error 2 error C2085: 'le16ToHost' : not in formal parameter list


    The function is declared like this:

    SHARED_FUNCTION WORD le16ToHost( BYTE * src );

    There's any problem with the way i'm declaring de function? Shared Functions are different in Visual C++?

    Best regards.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Shared Functions Declaration

    Quote Originally Posted by ajorge
    The function is declared like this:

    SHARED_FUNCTION WORD le16ToHost( BYTE * src );
    What is SHARED_FUNCTION? I never saw it MSDN nor somewhere else.
    Where and how is it #defined?
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2006
    Location
    Croatia - Zagreb
    Posts
    459

    Re: Shared Functions Declaration

    And make sure your C file has cpp extension before building.
    You just divided by zero, didn't you?

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Shared Functions Declaration

    Quote Originally Posted by Odiee
    And make sure your C file has cpp extension before building.
    although that is convention (IF the program is a C++ program [which has NOT been stated!!!!]), it is not a requirement, and I can not see how this has ANYTHING to do with the posters problem....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Oct 2008
    Posts
    27

    Re: Shared Functions Declaration

    Hi to all! I'm sorry for the few information i've writen

    The definition is:

    #ifndef __COMPILER_H
    #define __COMPILER_H



    //-----------------------------------------------------------------------------
    //
    //Windows Compiler specific section: This should be extracted to the
    //SMAlib system for compiler specific definitions. But first do it here....
    //
    //-----------------------------------------------------------------------------


    //##### Microsoft Compiler specific #####
    #if defined ( _MSC_VER ) || defined ( MSVCPP )

    //to reduce some define stuff...
    #define USING_MICROSOFT_COMPILER

    //don't ask....
    #if defined(_DLL) || defined (_WINDLL)
    #define __DLL__ 1
    #endif

    //building an DLL? => Mark functions with "export"
    //building host => Mark functions with "import"
    #ifdef __DLL__
    #define SHARED_FUNCTION __declspec(dllexport)
    #else
    #define SHARED_FUNCTION __declspec(dllimport)
    #endif

    //disable all deprecation warnings,
    #if (_MSC_VER >= 1400) // VC8+
    #pragma warning(disable : 4996)
    #endif

    //define it for the rest....
    #ifndef __WIN32__
    #define __WIN32__ 1
    #endif

    #endif


    //##### Borland C++Builder specific #####
    #ifdef __BORLANDC__

    //building an DLL? => Mark functions with "export"
    //building host => Mark functions with "import"
    #ifdef __DLL__
    #define SHARED_FUNCTION __declspec(dllexport)
    #else
    #define SHARED_FUNCTION __declspec(dllimport)
    #endif

    //for precompield head with borland compilers...stop caching here...
    #pragma hdrstop

    #endif


    //##### GNU C compiler specific Windows #####
    #ifdef __GNUC__
    #ifdef _WIN32
    //__cdecl or winapi
    #define SHARED_FUNCTION __cdecl
    #else
    /* U*nix: Linux/NetBSD/SOLARIS/... */
    #define SHARED_FUNCTION
    #endif

    #endif



    #endif /*__COMPILER_H*/


    The function declaration is:

    SHARED_FUNCTION WORD le16ToHost( BYTE * src );

    And the function definition is:

    WORD le16ToHost( BYTE * src )
    {
    return ((src[0] ) | (src[1]<<8 ));
    }

    The errors were the mentioned before in my first post.

    Best Regards.

  6. #6
    Join Date
    Feb 2002
    Posts
    3,788

    Re: Shared Functions Declaration

    so how are you using le16ToHost in your code?

  7. #7
    Join Date
    Oct 2008
    Posts
    27

    Re: Shared Functions Declaration

    I'm trying to create a dll file using this function and others of the same type.

  8. #8
    Join Date
    Oct 2008
    Posts
    27

    Re: Shared Functions Declaration

    Thanks! I already detect the problem origin. It was the compiler selection routine. Wasn't working

    Best regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured