From: Giovanni Dicanio on


"bachegool" <esadeghi48(a)gmail.com> ha scritto nel messaggio
news:3f29561b-2bd7-4584-a71e-d4f68bf7a41c(a)j19g2000vbp.googlegroups.com...

> No, the include files belong to the whole MFC app which I have also
> included the function. but how can I export a pure C function from
> this dll?

You can provide a public header file for the client of the DLL.
This header file can have a form something like this:

----[ MyDll.h ]----

// FILE: MyDll.h
// DESC: Public header file to be used by DLL clients.

// DLL header included only once in the project
#ifndef MYDLL_H_INCLUDED
#define MYDLL_H_INCLUDED

// Begin C++ guard
#ifdef __cplusplus
extern "C" {
#endif

// DLL implementation must #define MYDLL_API
// as __declspec(dllexport) *before* including this header.
// DLL client just doesn't need to do anything about that.
#ifndef MYDLL_API
#define MYDLL_API __declspec(dllimport)
#endif

// Calling convention used by DLL exported functions
#define MYDLL_CALLCONVENTION __stdcall


// DLL public function, with a pure C interface
MYDLL_API void MYDLL_CALLCONVENTION
MyDll_DoSomething(
/* ... parameters here */
);


// End C++ guard
#ifdef __cplusplus
};
#endif


#endif // MYDLL_H_INCLUDED

----[ End of MyDll.h ]----

Basically, in the DLL public header, there is no reference to #include's of
MFC specific stuff, because MFC is used only *inside* the DLL
implementation, but the client of the DLL can be a normal Win32 app, not
using MFC.

Giovanni


From: bachegool on
On Oct 5, 10:42 am, "Giovanni Dicanio"
<giovanniDOTdica...(a)REMOVEMEgmail.com> wrote:
> "bachegool" <esadegh...(a)gmail.com> ha scritto nel messaggionews:3f29561b-2bd7-4584-a71e-d4f68bf7a41c(a)j19g2000vbp.googlegroups.com...
>
> > No, the include files belong to the whole MFC app which I have also
> > included the function. but how can I export a pure C function from
> > this dll?
>
> You can provide a public header file for the client of the DLL.
> This header file can have a form something like this:
>
> ----[ MyDll.h ]----
>
> // FILE: MyDll.h
> // DESC: Public header file to be used by DLL clients.
>
> // DLL header included only once in the project
> #ifndef MYDLL_H_INCLUDED
> #define MYDLL_H_INCLUDED
>
> // Begin C++ guard
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> // DLL implementation must #define MYDLL_API
> // as __declspec(dllexport) *before* including this header.
> // DLL client just doesn't need to do anything about that.
> #ifndef MYDLL_API
> #define MYDLL_API __declspec(dllimport)
> #endif
>
> // Calling convention used by DLL exported functions
> #define MYDLL_CALLCONVENTION __stdcall
>
> // DLL public function, with a pure C interface
> MYDLL_API void MYDLL_CALLCONVENTION
>     MyDll_DoSomething(
>         /* ... parameters here */
>     );
>
> // End C++ guard
> #ifdef __cplusplus};
>
> #endif
>
> #endif // MYDLL_H_INCLUDED
>
> ----[ End of MyDll.h ]----
>
> Basically, in the DLL public header, there is no reference to #include's of
> MFC specific stuff, because MFC is used only *inside* the DLL
> implementation, but the client of the DLL can be a normal Win32 app, not
> using MFC.
>
> Giovanni

Thanks, I created a new include file with just the function in it and
used that as a include file. everything is working now.
ehsan
From: bachegool on
On Oct 5, 10:42 am, "Giovanni Dicanio"
<giovanniDOTdica...(a)REMOVEMEgmail.com> wrote:
> "bachegool" <esadegh...(a)gmail.com> ha scritto nel messaggionews:3f29561b-2bd7-4584-a71e-d4f68bf7a41c(a)j19g2000vbp.googlegroups.com...
>
> > No, the include files belong to the whole MFC app which I have also
> > included the function. but how can I export a pure C function from
> > this dll?
>
> You can provide a public header file for the client of the DLL.
> This header file can have a form something like this:
>
> ----[ MyDll.h ]----
>
> // FILE: MyDll.h
> // DESC: Public header file to be used by DLL clients.
>
> // DLL header included only once in the project
> #ifndef MYDLL_H_INCLUDED
> #define MYDLL_H_INCLUDED
>
> // Begin C++ guard
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> // DLL implementation must #define MYDLL_API
> // as __declspec(dllexport) *before* including this header.
> // DLL client just doesn't need to do anything about that.
> #ifndef MYDLL_API
> #define MYDLL_API __declspec(dllimport)
> #endif
>
> // Calling convention used by DLL exported functions
> #define MYDLL_CALLCONVENTION __stdcall
>
> // DLL public function, with a pure C interface
> MYDLL_API void MYDLL_CALLCONVENTION
>     MyDll_DoSomething(
>         /* ... parameters here */
>     );
>
> // End C++ guard
> #ifdef __cplusplus};
>
> #endif
>
> #endif // MYDLL_H_INCLUDED
>
> ----[ End of MyDll.h ]----
>
> Basically, in the DLL public header, there is no reference to #include's of
> MFC specific stuff, because MFC is used only *inside* the DLL
> implementation, but the client of the DLL can be a normal Win32 app, not
> using MFC.
>
> Giovanni

Thanks, I created a new include file with just the function in it and
used that as a include file. everything is working now.
ehsan
From: Giovanni Dicanio on


"bachegool" <esadeghi48(a)gmail.com> ha scritto nel messaggio
news:f6cc8a92-328a-4e78-8b45-f646c3c71cea(a)d4g2000vbm.googlegroups.com...

> Thanks, I created a new include file with just the function in it and
> used that as a include file. everything is working now.

You're welcome.
Glad that it works.

Giovanni