• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 442
  • Last Modified:

how to export a MACRO in dll

I crreated a DLL and want to export a few MACROs.
#define ALLOCATE_MEMORY( result , type , number ) \
( (result = ( type *) allocate( ( number ) * sizeof( type ))))
it does not allow me to put '__declspec(dllexport)' in front of #define ...

Could anyone tell me how to solve this?
2 Solutions
Macros are replaced where they are used by the preprocessor with what they are defined by, so there is no way to export the macro itself because it doesn't exist in the binary.  You can put it in a header file and if the function called in the macro is exported by the dll and imported by your application you should be able to use the macro after including the header file.
Macros are only used during compile time (during preprocessing). Convert the macro to a function and then you will be able to export it.
lzha022Author Commented:
Oh, i see.
thanks for both of you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now