Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

how to export a MACRO in dll

I crreated a DLL and want to export a few MACROs.
eg.
#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?
thanks
 
0
lzha022
Asked:
lzha022
2 Solutions
 
DefreeComanCommented:
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.
0
 
Anthony2000Commented:
Macros are only used during compile time (during preprocessing). Convert the macro to a function and then you will be able to export it.
0
 
lzha022Author Commented:
Oh, i see.
thanks for both of you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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