2

I'm dealing with someone else's code. From the docs, I see that the header may be all that is need to explain why I get 4

Severity    Code    Description Project File    Line    Suppression State
Warning C4273   'DTAIAEC_<Init/Run/Shutdown/Push>': inconsistent dll linkage

Two definitions in a file differ in their use of dllimport. _WIN32 is "always true". I guess that __declspec conflicts with extern "C" My question is how to solve it with:

#pragma once


#ifdef _WIN32
#ifdef DTAI_AEC_EXPORTS
#define DTAI_AEC_API __declspec(dllexport)
#else
#define DTAI_AEC_API __declspec(dllimport)
#endif
#else
#define DTAI_AEC_API
#endif

#include <vector>

#pragma pack(push, 1)

typedef struct {
}DTAIAEC_Multi_SoundBuffer;

typedef struct {
}DTAIAEC_Output_SoundBuffer;

#pragma pack(pop)

typedef int(*DTAIAEC_SoundBuffer_Output_CB_t) (DTAIAEC_Output_SoundBuffer*);

extern "C" DTAI_AEC_API int DTAIAEC_Init(DTAIAEC_SoundBuffer_Output_CB_t SoundBuffer_Res_Callback, int internalChannels);

extern "C" DTAI_AEC_API int DTAIAEC_Run(void);

extern "C" DTAI_AEC_API int DTAIAEC_Shutdown(void);

extern "C" DTAI_AEC_API int DTAIAEC_Push(DTAIAEC_Multi_SoundBuffer*);
Julius Baer
  • 61
  • 10
  • Does this answer your question? [About inconsistent dll linkage](https://stackoverflow.com/questions/2592523/about-inconsistent-dll-linkage) – Paul Sanders Aug 19 '20 at 22:28
  • I understand that in `extern...` DTAI_AEC_API is replaced by __declspec(dllimport) in programs that need to import my module and exported by my module itself. https://support.microsoft.com/en-us/help/128199 is a dead link. DTAI_AEC_EXPORTS is defined in the project files (Preprocessor Definitions). once – Julius Baer Aug 20 '20 at 01:22
  • Do you get the warning on the lines in the header, or in a source file somewhere else (with the various `DTAIAEC` functions declared as `__declspec(dllexport)`)? Are you using a precompiled header? – 1201ProgramAlarm Aug 20 '20 at 01:28
  • But indeed, an importing project references this header. So, can / should / how to fix this? (It won't be imported by any other projects than the one that imports it now. – Julius Baer Aug 20 '20 at 01:29
  • I get the warning in the .cpp files that implement the header. Not in the importing module (i.e. main). – Julius Baer Aug 20 '20 at 01:31
  • `int DTAIAEC_Run(void){}` – Julius Baer Aug 20 '20 at 01:57

0 Answers0