从 VSStudio 获得 C2628 奇怪的错误,那里的所有分号
Getting C2628 strange error from VSStudio with all semicolon there
我正在使用embedFiglet,一个可嵌入的Figlet版本。虽然我在 Os X 上编译没有问题,但在带有 VS 的 Windows 10 下,我收到一个
..depembedfigletsrcFiglet.hh(341): error C2628: 'Figlet::Banner' followed by 'char' is illegal (did you forget a ';'?)
..depembedfigletsrcFiglet.hh(341): warning C4091: 'extern ': ignored on left of 'Figlet::Banner' when no variable is declared
ninja: build stopped: subcommand failed.
CXX 编译器标识为 MSVC 19.16.27026.1
这是代码:
#ifndef FIGLET_HH
#define FIGLET_HH
#include <iostream>
#include <stdint.h>
/*! brief
* Collects structures and classes for banner generation
*/
namespace Figlet {
using namespace std;
typedef std::basic_ostream<char> ostream_type;
static unsigned const maxHeight = 10; //!< maximum allowed (lines) height of the font
static unsigned const maxLenght = 256; //!< maximum number of characters x line of the banner
static unsigned const maxTableSize = 256; //!< maximum number of allowed character x font
//! Structure used to store a charater of the font
typedef struct {
unsigned short nchar; //!< character (ascii) number
uint8_t lspaces[maxHeight]; //!< number of spaces on the left side x line
uint8_t rspaces[maxHeight]; //!< number of spaces on the right side x line
char const * rows[maxHeight]; //!< charater definition
} FontFiglet;
//! Available way to print a string, see ref printmode
typedef enum {
FIGLET_SMUSHED=0,
FIGLET_PACKED,
FIGLET_FULLWIDTH,
FIGLET_MONOSPACED
} PrintMode;
//! Available way to print a frames string, see ref framemode
typedef enum { FIGLET_SINGLE=0, FIGLET_DOUBLE } FrameMode;
//! Class implementing the "figlet" algorithm
class Banner {
FontFiglet const * characters; //!< pointer to the font structures
char const Hardblank; //!< character used for the "hardblank" in the font definition
unsigned const Height; //!< vertical dimension (lines) of the font
unsigned Width; //!< width of the charater M used in Monospaced print
unsigned const FontMaxLen; //!< maximum width of the letters of the font
unsigned const FontSize; //!< total number of characters in the font
uint8_t rspaces[maxHeight]; //!< extra right spaces availables after the last insertion
char lines[maxHeight][maxLenght]; //!< lines buffer
char smush[maxHeight]; //!< charater used in the "smushing" algorithm
unsigned short charToTable[maxTableSize]; //!< map ascii character to font structure
unsigned short charWidth[maxTableSize]; //!< size width of each charater of the font
unsigned charPosition; //!< position of last inserted character
PrintMode printMode; //!< the type of printing mode used
Banner const & operator = ( Banner const & );
Banner( Banner const & );
//! evaluate smushing rules for 2 characters, return ' ' if no rules apply
char smushingRules( char left, char right ) const;
bool pushMonospaced( unsigned c );
bool pushFullWidth( unsigned c );
bool pushPacked( unsigned c );
bool pushSmushed( unsigned c );
void fillForPrint( char const message[] );
public:
//! Constructor of `Banner` class
/*!
:|: param characters none
:|: param Hardblank none
:|: param Height none
:|: param FontMaxLen none
:|: param FontSize none
*/
explicit
Banner( FontFiglet const * characters,
char Hardblank,
unsigned Height,
unsigned FontMaxLen,
unsigned FontSize );
//! initialize Banner class
void init();
//! Set print mode to `monospaced`, see ref printmode
void setMonospaced() { printMode = FIGLET_MONOSPACED; }
//! Set print mode to `full width`, see ref printmode
void setFullWidth() { printMode = FIGLET_FULLWIDTH; }
//! Set print mode to `packed`, see ref printmode
void setPacked() { printMode = FIGLET_PACKED; }
//! Set print mode to `smushed` (figlet default), see ref printmode
void setSmushed() { printMode = FIGLET_SMUSHED; }
//! Print large letters of string `message` on stream `s`, see ref printmode
unsigned
print(
char const message[],
ostream_type & s = cout,
char const top[] = "",
char const bottom[] = ""
);
//! ref framemode
void
printFramed(
char const message[],
ostream_type & s = cout,
FrameMode fm = FIGLET_SINGLE
);
};
extern Banner big; //!< instance `Banner` class using figlet font `big`
extern Banner banner; //!< instance `Banner` class using figlet font `banner`
extern Banner doom; //!< instance `Banner` class using figlet font `doom`
extern Banner larry3d; //!< instance `Banner` class using figlet font `larry3d`
extern Banner mini; //!< instance `Banner` class using figlet font `mini`
extern Banner script; //!< instance `Banner` class using figlet font `script`
extern Banner small; //!< instance `Banner` class using figlet font `small`
extern Banner standard; //!< instance `Banner` class using figlet font `standard`
extern Banner straight; //!< instance `Banner` class using figlet font `straight`
extern Banner bulbhead; //!< instance `Banner` class using figlet font `bulbhead`
};
#endif
//
// eof: Figlet.hh
//
(341行是带有"外部横幅小"的行;
现在,除非我的眼睛摇摇晃晃,否则我会看到所有分号都到位。我是Windows环境的新手,所以我想问题一定是别的。一周前,我已经能够正确编译。成功了。现在没有了。
请问你们中有人能更专业的人照亮一盏灯吗?
只需测试使用Goldbolt网站独立编译此代码就可以正常工作,Visual Studio(MSVC)和Clang都可以使用。
我猜也许您在文件(或包含的标头)的其他地方有一个定义,将"小"定义为"char"(或类似的东西),但您没有在您粘贴的代码部分中显示它(您是否也单独测试了这一小部分?
相关文章:
- 警告处理为错误这里有什么问题
- "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()中运行,但在函数中出现错误
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 我无法在某个点(从用户那里)获得输入,即使没有错误弹出编译
- 从 VSStudio 获得 C2628 奇怪的错误,那里的所有分号
- 使用 std、vector 和 bitvec C++代码中的错误以及如何从用户那里获取输入
- C:主要未找到,但它在那里 |编译错误
- 从朋友那里访问私有变量,我认为我的语法是错误的
- 奇怪的链接错误。找不到符号,尽管 nm 验证它在那里
- C++ Qt框架:qmake退出错误代码2,找不到 project.pro 文件,但它就在那里