微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

“Mk4tcl_Init”:不允许定义 dllimport 函数

如何解决“Mk4tcl_Init”:不允许定义 dllimport 函数

我正在构建一个 Tcl 模块 mk4tcl一个 .dll)(part of metakit project),我没有在互联网上找到这个已经构建的模块,这就是我手动构建它的原因.然而,这个模块已经在 ActiveTcl 中编译,但在 Tcl 中没有。我必须在 Tcl 中使用它,因为我是从源代码构建 Tcl。

使用 nmake 构建时出现以下错误

..\src\mk4tcl.cpp(2597): error C2491: 'Mk4tcl_Init': deFinition of dllimport function not allowed
..\src\mk4tcl.cpp(2601): error C2491: 'Mk_Init': deFinition of dllimport function not allowed
..\src\mk4tcl.cpp(2605): error C2491: 'Mk4tcl_SafeInit': deFinition of dllimport function not allowed 
..\src\mk4tcl.cpp(2609): error C2491: 'Mk_SafeInit': deFinition of dllimport function not allowed
NMAKE : Fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\cl.EXE"' : return code '0x2'

我正在使用 C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars32.bat

它是旧项目,它也有 dsp 项目和 vcprojects,但在构建时发生了同样的错误。 我安装了 Visual Studio 6 来构建 mktcl.dsp 项目,但同样的错误再次发生。 我尝试了以下解决方definition of dllimport function not allowed

这个模块使用 tcl.h 我有版本 8.6.11

mk4tcl.cpp(部分)

#include "../tcldir/tcl.h"

EXTERN int Mk4tcl_Init(Tcl_Interp *interp) {
  return Mktcl_Cmds(interp,false);
}

EXTERN int Mk_Init(Tcl_Interp *interp) {
  return Mktcl_Cmds(interp,false);
}

EXTERN int Mk4tcl_SafeInit(Tcl_Interp *interp) {
  return Mktcl_Cmds(interp,true);
}

EXTERN int Mk_SafeInit(Tcl_Interp *interp) {
  return Mktcl_Cmds(interp,true);
}

tcl.h(定义的一部分)

#ifdef __cplusplus
extern "C" {
#endif

#ifndef USE_TCL_STUBS
#define Tcl_InitStubs(interp,version,exact) \
    Tcl_PkgInitStubsCheck(interp,exact)
#endif


#if (defined(_WIN32) && (defined(_MSC_VER) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0550)) || defined(__LCC__) || defined(__WATCOMC__) || (defined(__GNUC__) && defined(__declspec))))
#   define HAVE_DECLSPEC 1
#   ifdef STATIC_BUILD
#       define DLLIMPORT
#       define DLLEXPORT
#       ifdef _DLL
#           define CRTIMPORT __declspec(dllimport)
#       else
#           define CRTIMPORT
#       endif
#   else
#       define DLLIMPORT __declspec(dllimport)
#       define DLLEXPORT __declspec(dllexport)
#       define CRTIMPORT __declspec(dllimport)
#   endif
#else
#   define DLLIMPORT
#   if defined(__GNUC__) && __GNUC__ > 3
#       define DLLEXPORT __attribute__ ((visibility("default")))
#   else
#       define DLLEXPORT
#   endif
#   define CRTIMPORT
#endif


#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
#   define TCL_STORAGE_CLASS DLLEXPORT
#else
#   ifdef USE_TCL_STUBS
#      define TCL_STORAGE_CLASS
#   else
#      define TCL_STORAGE_CLASS DLLIMPORT
#   endif
#endif


#ifdef EXTERN
#   undef EXTERN
#endif /* EXTERN */

#ifdef __cplusplus
#   define EXTERN extern "C" TCL_STORAGE_CLASS
#else
#   define EXTERN extern TCL_STORAGE_CLASS
#endif


#define Tcl_Main(argc,argv,proc) Tcl_MainEx(argc,proc,\
        ((Tcl_CreateInterp)()))
EXTERN void     Tcl_MainEx(int argc,char **argv,Tcl_AppInitProc *appInitProc,Tcl_Interp *interp);
EXTERN const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp,const char *version,int exact);
EXTERN void     Tcl_GetMemoryInfo(Tcl_DString *dsPtr)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?