Hi VC++ Developers

I'm trying to learn how to write simple DLLs.
The following is the code excepts I developed in the process.
I created a MFC shared MFC DLL project... and inserted
the following three files, see below. I get the following error:

Compiling...
DLLCode.cpp
c:\program files\microsoft visual studio\vc98\include\errno.h(29)
: error C2143: syntax error : missing ';' before 'string'
c:\program files\microsoft visual studio\vc98\include\errno.h(29)
: fatal error C1004: unexpected end of file found

I to not know why it error message is appearing??
I'm uses VC++ 6.0 SP5

Thanks in advance

King

/*********************************************************************
File name: DLLDIR.h

Notice: we use the same header file for compiling the .dll and the .exe
(application).
This header file defines a macro to export the target DLL objects if we
are building
a DLL, and import the DLL objects into an application which uses the DLL.
If we define
DLLDIR_EX, DLLDIR becomes an export instruction, otherwise its an import
instruction
by default.
**********************************************************************/

#ifndef DLLDIRECTION_H
#define DLLDIRECTION_H

#ifdef DLLDIR_EX
#define DLLDIR __declspec(dllexport)
#else
#define DLLDIR __declspec(dllimport)
#endif

#endif // DLLDIRECTION_H

//==============================================================


/***********************************************************************
File name: DLLCode.h

This file contains all the DLL interfacing object declarations, in this
case: a class
object, a global function object, and a global integer variable.
************************************************************************/
#include "DLLDIR.h"

extern "C" {
int DLLDIR DLLfun(int);
int DLLDIR DLLArg;
}

class DLLDIR Dllclass
{
public:
Dllclass(); // Class Constructor
~Dllclass(); // Class destructor
int Add(int, int); // Class function Add
int Sub(int, int); // Class function Subtract
int Arg;
}

//============================================================

/********************************************************************
File name: DLLCode.cpp

The header file, DLLCode.h, prototypes all of the DLL interface objects
*********************************************************************/

#include "StdAfx.h"
#include "DLLCode.h"
#include <iostream>

using namespace std;

int DLLfun(int a)
{
cout << "the number pass to DLLfun is: " << a << endl;
return a<<1;
}

int DLLArg = 100;

Dllclass::Dllclass() {};

Dllclass::~Dllclass() {};

int Dllclass::Add(int a, int b)
{
return a + b;
}

int Dllclass::Sub(int a, int b)
{
return a - b;
}

//=========================================================

Re: Compiling a simple DLL by Igor

Igor
Wed Mar 03 14:34:46 CST 2004

"King Coffee" <kcoffee@pconline.com> wrote in message
news:104cfspn4lsc2f8@corp.supernews.com...
> I'm trying to learn how to write simple DLLs.
> The following is the code excepts I developed in the process.
> I created a MFC shared MFC DLL project... and inserted
> the following three files, see below. I get the following error:
>
> class DLLDIR Dllclass
> {
> public:
> Dllclass(); // Class Constructor
> ~Dllclass(); // Class destructor
> int Add(int, int); // Class function Add
> int Sub(int, int); // Class function Subtract
> int Arg;
> }

You are missing a semicolon after the closing brace.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Re: Compiling a simple DLL by Wanjun

Wanjun
Wed Mar 03 14:40:13 CST 2004

try moving <iostream> to stdafx.h or dllcode.h.

WJ

"King Coffee" <kcoffee@pconline.com> wrote in message
news:104cfspn4lsc2f8@corp.supernews.com...
> Hi VC++ Developers
>
> I'm trying to learn how to write simple DLLs.
> The following is the code excepts I developed in the process.
> I created a MFC shared MFC DLL project... and inserted
> the following three files, see below. I get the following error:
>
> Compiling...
> DLLCode.cpp
> c:\program files\microsoft visual studio\vc98\include\errno.h(29)
> : error C2143: syntax error : missing ';' before 'string'
> c:\program files\microsoft visual studio\vc98\include\errno.h(29)
> : fatal error C1004: unexpected end of file found
>
> I to not know why it error message is appearing??
> I'm uses VC++ 6.0 SP5
>
> Thanks in advance
>
> King
>
> /*********************************************************************
> File name: DLLDIR.h
>
> Notice: we use the same header file for compiling the .dll and the .exe
> (application).
> This header file defines a macro to export the target DLL objects if we
> are building
> a DLL, and import the DLL objects into an application which uses the
DLL.
> If we define
> DLLDIR_EX, DLLDIR becomes an export instruction, otherwise its an
import
> instruction
> by default.
> **********************************************************************/
>
> #ifndef DLLDIRECTION_H
> #define DLLDIRECTION_H
>
> #ifdef DLLDIR_EX
> #define DLLDIR __declspec(dllexport)
> #else
> #define DLLDIR __declspec(dllimport)
> #endif
>
> #endif // DLLDIRECTION_H
>
> //==============================================================
>
>
> /***********************************************************************
> File name: DLLCode.h
>
> This file contains all the DLL interfacing object declarations, in this
> case: a class
> object, a global function object, and a global integer variable.
> ************************************************************************/
> #include "DLLDIR.h"
>
> extern "C" {
> int DLLDIR DLLfun(int);
> int DLLDIR DLLArg;
> }
>
> class DLLDIR Dllclass
> {
> public:
> Dllclass(); // Class Constructor
> ~Dllclass(); // Class destructor
> int Add(int, int); // Class function Add
> int Sub(int, int); // Class function Subtract
> int Arg;
> }
>
> //============================================================
>
> /********************************************************************
> File name: DLLCode.cpp
>
> The header file, DLLCode.h, prototypes all of the DLL interface objects
> *********************************************************************/
>
> #include "StdAfx.h"
> #include "DLLCode.h"
> #include <iostream>
>
> using namespace std;
>
> int DLLfun(int a)
> {
> cout << "the number pass to DLLfun is: " << a << endl;
> return a<<1;
> }
>
> int DLLArg = 100;
>
> Dllclass::Dllclass() {};
>
> Dllclass::~Dllclass() {};
>
> int Dllclass::Add(int a, int b)
> {
> return a + b;
> }
>
> int Dllclass::Sub(int a, int b)
> {
> return a - b;
> }
>
> //=========================================================
>
>
>