Search code examples
clangc++builderclang++

clang [bcc32c Warning] redeclaration should not add 'dllexport' attribute


I am creating a DLL and exporting a SimpleMAPI DLL function and one of the functions signature is as following:

extern "C" ULONG __declspec(dllexport) WINAPI MAPISendMail(LHANDLE lhSession, ULONG_PTR ulUIParam, lpMapiMessage lpMessage, FLAGS flFlags, ULONG ulReserved);

I am using C++ Builder, using clang compiler. Compiler issues warning:

[bcc32c Warning]: redeclaration of 'MAPISendMail' should not add 'dllexport' attribute mapi.h(262): previous declaration is here

It compiles and works, but I am bothered by this warning. Can it be avoided?


Solution

  • As @RemyLebeau pointed out, the warnings happened because I included <mapi.h> header.

    If MAPI DLL is being created (creating your own DLL that other programs will use or exporting MAPI functions), so if one is implementing MAPI support in their own program, then the required structures and #define are copied from the original mapi.h file into a custom header file which is then included. #define such as FLAGS or MapiMessage struct.

    If MAPI is being used (so using calling MAPI functions from other DLL, or other programs) then <mapi.h> is included.

    So after creating a custom mapidefs.h file which only contained required structures and #define, the problem is now solved.

    There is also this example on StackOverflow as well.