visual c++ MSVC dll编译错误,缺少类型说明符和重定义

visual C++ MSVC dll compiling error missing type specifier and redefinition

本文关键字:类型 说明符 定义 MSVC c++ dll 编译 错误 visual      更新时间:2023-10-16

我正在使用Microsoft Visual Studio Community 2015 Update 3,正在编译一个dll。我想调用InitPreySplitPipe函数,我已经尝试用::pr::InitPreySplitPipe调用它,我将interprocess.cpp代码复制到game_local.cpp和interprocess.hpp代码复制到game_local.h并从那里调用它,但这也不起作用。

如果有人感兴趣,我已经建立了一个GitHub存储库与所有的代码。

谢谢你的阅读,抱歉我的英语不好:/

编译器输出:

Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int
Error C2371 'pr::InitPreySplitPipe': redefinition; different basic types
Error C2556 'int InitPreySplitPipe(void)': overloaded function differs only by return type from 'void pr::InitPreySplitPipe(void)'
<标题> interprocess.hpp h1> interprocess.cpp h1> /函数应该被调用的地方 <标题> game_local.cpp h1> div class="answers">

In game_local.cpp:

// PreyRun BEGIN
#include "../PreyRun/interprocess.hpp"
pr::InitPreySplitPipe();
// PreyRun END

你没有从任何内部调用函数,所以编译器认为这是一个新的函数声明。因此,假定类型为int,其重载函数int pr:InitPreySplitPipe()void pr::InitPreySplitPipe()冲突。这解释了所有3个错误消息。