how to export a MACRO in dll

Posted on 2007-07-23
Last Modified: 2008-01-09
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?
Question by:lzha022
    LVL 3

    Accepted Solution

    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.
    LVL 8

    Assisted Solution

    Macros are only used during compile time (during preprocessing). Convert the macro to a function and then you will be able to export it.

    Author Comment

    Oh, i see.
    thanks for both of you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Top Freelancers to Complete C++ Projects

    Source the talented Expert Exchange community
    for top quality work on your C++ projects.

    Hire the best. Collaborate easily. Get quality work.

    Article by: SunnyDark
    This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
    This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now