c++visual-studio-2010visual-c++dllstdafx.h

Share header files within two Visual Studio 2010 C++ projects ( DLL and a Win32 project)


I have two VS10 projects, one is a (not MFC) DLL. I want to use in the DLL project a struct defined in one header file of the other project. The projects use the precompiled headers and all the includes are made under stdafx.h.

Project One

struct example
{
  int a;
  int b;
};

DLL Project

#include "stdafx.h"


extern "C"
{

    __declspec(dllexport) int ex(struct example *p)
    {
        int c = p->a;

        return 1;
    }


}

struct example must be visible from the DLL project. How can I achieve that?


Solution

  • This can be solved at compile time by putting the Struct in a separate header file and including it in both projects.