|
-
October 28th, 2008, 06:36 AM
#1
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.
-
October 28th, 2008, 07:52 AM
#2
Re: Shared Functions Declaration
 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
-
October 28th, 2008, 08:42 AM
#3
Re: Shared Functions Declaration
And make sure your C file has cpp extension before building.
You just divided by zero, didn't you?
-
October 28th, 2008, 08:58 AM
#4
Re: Shared Functions Declaration
 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
-
October 28th, 2008, 09:28 AM
#5
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.
-
October 28th, 2008, 09:33 AM
#6
Re: Shared Functions Declaration
so how are you using le16ToHost in your code?
-
October 28th, 2008, 09:37 AM
#7
Re: Shared Functions Declaration
I'm trying to create a dll file using this function and others of the same type.
-
October 28th, 2008, 09:52 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|