外部 "C" Visual Studio 2015 中的显式类型错误,DLL 测试代码

Extern "C" explicit type error in Visual Studio 2015, DLL test code

本文关键字:错误 类型 测试 代码 DLL Visual Studio 2015 外部      更新时间:2023-10-16

我正在尝试编译一组非常基本的代码来测试在R中使用VS15 C++制作的DLL的功能。我遵循了本教程: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 给了我以下与 stdafx.h 对应的错误:

explicit type is missing ('int' assumed)    
expected a ';'  

任何见解都非常感谢。

干杯!

你的代码中真的有智能引号吗:extern “C”

我怀疑您可能这样做,因为您从中剪切或粘贴代码的网站也有它们(在我看来,很多,可能是寻找另一个网站的一个很好的理由,但你同样可以使用他们的代码,只要你很乐意修复其中的错误(。

你应该用更愚蠢(但更容易接受(的引号替换它们:

extern "C" __declspec(dllexport) void __cdecl foo(double *in, double *out);
//     ^ ^
//     Here

顺便说一句,我在网站上留下了一条评论,建议他们解决问题(目前正在等待审核(。