I have been trying for a while to create a DLL via Visual Studio 2019. Most of the files are .cpp and their headers (.cpp & .h), but there is one which is .c file (and its header).
When I include "pch.h" from the .c file, I get the following error:
Error C1853 precompiled header file is from a different version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)
Among of the tries I did, but unfortunately none of them worked:
Replaced the suffix from .c to .cpp, and tried the opposite too (all the .cpp to .c)
#include "stdafx.h" instead of #include "pch.h"
I have also created another DLL (the example from MSDN site) to see how should it be, and from what it seems - the only problem is caused by the .c file.
The sites where I was looking for any good solution to my problem:
- trying to create a dll file from both c and cpp files in visual studio 2017 (stack overflow)
- Calling C DLL from C# (stack overflow)
- C-DLL from C++ source (stack overflow)
- Walkthrough: Create and use your own Dynamic Link Library (C++) (MSDN)
- Possible to call C++ code from C#? (stack overflow)
- C++ backend with C# frontend? (stack overflow)
- Compile a DLL in C/C++, then call it from another program (stack overflow)
And more sites....
I am doing this to have a connection between my C/C++ code to my GUI (C#, WindowsForms). Hence, if you might have a better general solution instead of creating a dll, or any suggestions about fixing this issue, it will be great to read!
My question may look similar to other questions, but I couldn't find an answer for mine. Sorry if there are any English mistakes. If there is anything wrong, I will fix it.
Thank you very much beforehand.