9

I have an issue with Visual studio (in C++)

I got a warning and I don't know why because I never call 2 time the same variable.

function: inconsistent dll linkage

warning list: (in french) warning list - visual studio c++

I read on microsoft: Compiler Warning (level 1) C4273 but I don't really know if it's my problem because the example is not like mine.

I read also About inconsistent dll linkage (StackOverflow and it tell me that because I use MFC in dll but I didn't check the header MFC. not MFC header

it's my "PayRespectdll.h"

#pragma once

#ifdef PAYRESPECTDLL_EXPORTS
#define PAYRESPECTDLL_API __declspec(dllexport) 
#else
#define PAYRESPECTDLL_API __declspec(dllimport) 
#endif

#include <ctime>
#include <time.h>
#include <string>

namespace PayRespectDLL
{
    class PayRespect
    {
    private:
        static struct std::tm when;
    public:
        static PAYRESPECTDLL_API bool is_setup();
        static PAYRESPECTDLL_API void setup(std::string date);
        static PAYRESPECTDLL_API bool is_possible();
    }
}

PayRespectDLL.cpp:

// PayRespectDLL.cpp :
//

#include "stdafx.h"
#include "PayRespectDLL.h"
#include <stdexcept>
#include <time.h>
#include <string>
#include <stdlib.h>


using namespace std;

namespace PayRespectdll
{
    bool PayRespect::is_setup()
    {
        return false;//already_setup;
    }

    // setup attempt String: hh:mm:ss.
    void PayRespect::setup(string date)
    {
        return;
    }

    bool PayRespect::is_possible()
    {
        return true;
    }
}

thank you!

Community
  • 1
  • 1
Jean-philippe Emond
  • 1,619
  • 2
  • 17
  • 29
  • 9
    You will get this warning when the compiler parsed the declaration and saw __declspec(dllimport). But then also saw the definition of the function. That cannot be correct of course, it can't be both imported from another DLL *and* implemented by your code. Most obvious reason this happened is that you forgot to define or mis-spelled PAYRESPECTDLL_EXPORTS – Hans Passant Feb 04 '16 at 15:06
  • When I call my dll from another apps.. I just need to add ".h"... not define something? I follow a tutorial for creating the dll and I think it never saw that I need to define something in my solution. Can you provide me a tutorial to define it properly? – Jean-philippe Emond Feb 04 '16 at 15:12
  • 6
    Right-click your DLL project > Properties > C/C++ > Preprocessor > Preprocessor definitions setting. Add PAYRESPECTDLL_EXPORTS. Repeat for all other configurations. This is supposed to be discoverable, spend another hour looking around. Press F1 when you don't understand something. – Hans Passant Feb 04 '16 at 15:16

0 Answers0