从 VSStudio 获得 C2628 奇怪的错误,那里的所有分号

Getting C2628 strange error from VSStudio with all semicolon there

本文关键字:那里 错误 C2628 获得 VSStudio      更新时间:2023-10-16

我正在使用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"(或类似的东西),但您没有在您粘贴的代码部分中显示它(您是否也单独测试了这一小部分?