- Subject: Re: Installer for WJED available
- From: Eugene Epshteyn <eugene_epshteyn@xxxxxxxxx>
- Date: Sun, 6 Mar 2005 02:12:36 -0800 (PST)
Attached is how I would recommend declaring SLang functions exported from a
Win32 DLL.
Then the actual function implementation (corresponding to the one mentioned
in the attached header file) would be declared like this:
// This is an example of an exported function.
SLANG_API int SLANG_CALL SomeSlangFunction(void)
{
...
}
If this method is used, then the client code using SLang from Win32 DLL just
needs to include the header file. Then the client can either call SLang
functions directly (which will cause the compiler to generate appropriate
import code and will bind the client to SLang DLL) or use
LoadLibrary/GetProcAddress calls.
I strongly recommend having SLANG_CALL macro defined (set to __cdecl in .h
file), because many Win32 projects use __stdcall calling convention by
default, and including header files with function without calling convention
will result in extra pain to the user.
--Eugene
--- "John E. Davis" <davis@xxxxxxxxxxxxx> wrote:
> SANGOI DINO <SANGOID@xxxxxxxxxxxxxxxxx> wrote:
> >I'm also trying to be able to use modules on windows. The runtime =
> >linking is
> >very easy: Windows has functions that map mostly 1:1 to Linux dlopen() =
> >and
> >friends.
>
> That's good to hear.
>
> >The problem is that Windows by default does not export symbols if not
> >explicity requested. You can request exporting using =
> >'__declspec(dllexport)'
> >on the function declaration, or creating a .def file containing all the
> >exported symbols, and passing this file to the linker.
>
> The source contains two types of symbols: those that are in the public
> API with names of the form SL* and those that are private to the
> library _pSL*. Would both need to be give the __declspec(dllexport)
> attribute?
>
> How does this work? Is it sufficient to do something like:
>
> #ifdef __WIN32__
> #define EXPORT __declspec(dllexport)
> #else
> #define EXPORT
> #endif
>
> and then change declarations in slang.h to, e.g.,
>
> EXPORT int SLang_get_error ();
>
> ?? Or must this be put in the source code where SLang_get_error is
> actually defined? And should the private symbols (_pSL*) get the same
> treatment? I will probably move some such as _pSLvsnprintf to the
> public API.
>
> What changes would be required to makefile.all to create such a dll?
>
> Thanks,
> --John
>
> --------------------------
> To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
> the word "unsubscribe" in the message body.
> Need help? Email <jed-users-owner@xxxxxxxxxxx>.
>
---
Eugene Epshteyn
Eugene_Epshteyn@xxxxxxxxx
http://www.epshteyn.net
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the SLANG_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// SLANG_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef __WIN32__
#ifdef SLANG_EXPORTS
#define SLANG_API __declspec(dllexport)
#else
#define SLANG_API __declspec(dllimport)
#endif
#ifndef SLANG_CALL
#define SLANG_CALL __cdecl
#endif // SLANG_CALL
#else // __WIN32__
#define SLANG_API
#define SLANG_CALL
#endif // __WIN32__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
SLANG_API int SLANG_CALL SomeSlangFunction(void);
#ifdef __cplusplus
} ; // Close extern "C"
#endif // __cplusplus
[2005 date index]
[2005 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]