I am trying to compile a very basic set of code to test functionality of using a VS15 C++-made DLL in R. I followed this tutorial: https://erpcoder.blog/2016/06/15/how-to-develop-a-c-dll-for-r-in-visual-studio-2015/
stdafx.h:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
extern “C” __declspec(dllexport) void __cdecl foo(double *in, double *out);
DLL_Test.cpp:
#include "stdafx.h"
void foo(double *in, double *out)
{
double value = in[0] * 2;
out[0] = value;
}
VS15 gives me the following errors corresponding to stdafx.h:
explicit type is missing ('int' assumed)
expected a ';'
Any insight is greatly appreciated.
Cheers!
Do you really have smart quotes in your code: extern “C”
?
I suspect you probably do because the site you're cut'n'pasting the code from also has them (and quite a few, probably a good reason to look for another site, in my opinion, but you could equally just use their code provided you're happy to fix the bugs in it).
You should replace them with dumber (but far more acceptable) quotes:
extern "C" __declspec(dllexport) void __cdecl foo(double *in, double *out);
// ^ ^
// Here
As an aside, I have left a comment on the site suggesting they fix the issue (currently awaiting moderation).