首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从全是分号的VSStudio获取C2628奇怪错误

从全是分号的VSStudio获取C2628奇怪错误
EN

Stack Overflow用户
提问于 2019-08-26 16:48:05
回答 1查看 76关注 0票数 0

我使用的是embedFiglet,一个可嵌入的Figlet版本。虽然我在Os X上编译没有问题,但在Windows 10和VS上,我收到了一个

代码语言:javascript
复制
..\dep\embedfiglet\src\Figlet.hh(341): error C2628: 'Figlet::Banner' followed by 'char' is illegal (did you forget a ';'?)
..\dep\embedfiglet\src\Figlet.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

代码如下:

代码语言:javascript
复制
#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 '\0' 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行是带有"extern Banner small;“的那行)

现在,除非我的眼睛摇摇晃晃,否则我会看到所有的分号。我是Windows环境的新手,所以我猜问题一定出在别的地方。就在一周前,我已经能够正确编译。啊,真灵。现在不会再有了。

能不能请你们中更有经验的人帮我照亮一下?

EN

回答 1

Stack Overflow用户

发布于 2019-08-26 16:58:55

只需使用goldbolt网站独立测试编译这段代码,Visual Studio (MSVC)和Clang都能正常工作。

我猜您可能在文件中的其他地方(或在包含的头文件中)定义了" small“到"char”(或沿着这些行的内容),但您没有在粘贴的代码部分中显示(您是否也单独测试了这一小部分?)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57654605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档