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.
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. :confused:
Where and how is it #defined?
Re: Shared Functions Declaration
And make sure your C file has cpp extension before building.
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....
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.
Re: Shared Functions Declaration
so how are you using le16ToHost in your code?
Re: Shared Functions Declaration
I'm trying to create a dll file using this function and others of the same type.
Re: Shared Functions Declaration
Thanks! I already detect the problem origin. It was the compiler selection routine. Wasn't working :)
Best regards.