cdecl错误:之前应为初始值设定项
cdecl error: expected initializer before
我对cdecl调用约定有问题:
void Test1(char* str, ...) // ok
{}
void cdecl Test2(char* str, ...) // error: expected initializer before 'Test2'
{}
int main()
{}
我应该怎么做才能使编译器识别cdecl调用约定?
谢谢!
平台:Windows 7;MinGW;GCC 4.6.1
我不能修改这些函数,因为它们是文件FRAMEWRK.H:中"Microsoft Excel Developer’s Kit,Version 14"的一部分
///***************************************************************************
// File: FRAMEWRK.H
//
// Purpose: Header file for Framework library
//
// Platform: Microsoft Windows
//...
// From the Microsoft Excel Developer's Kit, Version 14
// Copyright (c) 1997 - 2010 Microsoft Corporation. All rights reserved.
///***************************************************************************
...
//
// Function prototypes
//
#ifdef __cplusplus
extern "C" {
#endif
void far cdecl debugPrintf(LPSTR lpFormat, ...);
LPSTR GetTempMemory(size_t cBytes);
void FreeAllTempMemory(void);
...
EDIT注意:正如下面的注释所示,这个答案(以及所有类似的答案)在技术上是不正确的。我不会删除它,这样我们就不会失去评论。(结束编辑)
用两个下划线作为前缀,如下所示:__cdecl
这是C和C++程序的默认调用约定。将__cdecl修饰符放在变量或函数名之前
编译器被指示为系统函数使用C命名和调用约定:
// Example of the __cdecl keyword
_CRTIMP int __cdecl system(const char *);
有关Microsoft中cdecl的文档,请参阅此处。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- cdecl错误:之前应为初始值设定项