I am compiling in Visual Studio 2005
Are any changes required around extern "C" for it to compile in VS 2005?
I am making a simple Windows Console application
Project type: DLL
Started with Empty project
Header File Code:
**********************
ifndef _DLL_TUTORIAL_H_
#define _DLL_TUTORIAL_H_
#include %26lt;iostream%26gt;
#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif
extern "C"
{
DECLDIR int Add( int a, int b );
DECLDIR void Function( void );
}
CPP File Code
******************
#include %26lt;iostream%26gt;
#include "DLL_Tutorial.h"
#define DLL_EXPORT
extern "C"
{
DECLDIR int Add( int a, int b )
{
return( a + b );
}
DECLDIR void Function( void )
{
std::cout %26lt;%26lt; "DLL Called!" %26lt;%26lt; std::endl;
}
}
Error C4430: missing type specifier - int assumed. Note: C++ does not support default-int?
#include "DLL_Tutorial.h"
#define DLL_EXPORT
Is that order intended? I notice that your DLL_Tutorial.h is looking for DLL_EXPORT to be defined, but it won't be set yet at the point where it's included .
May or may not be the root of your problem -- did your error come with a line #? What line does it map to in the file?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment