Solaris:错误:'enum'之前的预期primary-expression

时间:2017-12-04 21:16:55

标签: c++ enums solaris

我在构建C ++代码包装器时尝试修复Solaris上的问题。 我得到的错误如下。

udpipe.cpp: In member function ‘void ufal::udpipe::multiword_splitter::append_token(ufal::udpipe::utils::string_piece, ufal::udpipe::utils::string_piece, ufal::udpipe::sentence&) const’:
udpipe.cpp:19770:3: error: expected primary-expression before ‘enum’
   enum casing_t { UC_FIRST, UC_ALL, OTHER };
   ^
udpipe.cpp:19771:21: error: ‘OTHER’ was not declared in this scope
   casing_t casing = OTHER;
                     ^
udpipe.cpp:19775:12: error: invalid conversion from ‘int’ to ‘ufal::udpipe::multiword_splitter::append_token(ufal::udpipe::utils::string_piece, ufal::udpipe::utils::string_piece, ufal::udpipe::sentence&) const::casing_t’ [-fpermissive]
     casing = UC_ALL;
        ^

出现问题的C ++代码位于以下部分(包含以下代码的完整代码位于https://github.com/bnosac/udpipe/blob/master/src/udpipe.cpp)。 代码在gcc,clang和Windows上正常运行,但在Solaris上运行不正常。知道我需要做些什么来解决这个问题吗?

FYI。编译udpipe.cpp的命令如下:

/opt/csw//bin/g++ -std=gnu++11 -I/home/ripley/R/gcc/include -DNDEBUG  -I"/home/ripley/R/Lib32/Rcpp/include" -I/opt/csw/include -I/usr/local/include   -fPIC  -O2 -c udpipe.cpp -o udpipe.o

该机器具有C ++,C ++,来自Oracle Developer Studio 12.5的Fortran,具有以下配置设置:

CC="/opt/csw//bin/gcc"
CFLAGS=-O2
CPPFLAGS="-I/opt/csw/include -I/usr/local/include"
F77="/opt/csw//bin/gfortran"
FFLAGS=-O2
CXX="/opt/csw//bin/g++"
CXXFLAGS=-O2
FC=$F77
FCFLAGS=-O2
LDFLAGS="-L/opt/csw/lib -L/usr/local/lib"

代码如下所示

void multiword_splitter::append_token(string_piece token, string_piece misc, sentence& s) const {
  using namespace unilib;

  // Buffer
  s.add_word();
  string& buffer = s.words.back().form;

  // Lowercase the token
  utf8::map(unicode::lowercase, token.str, token.len, buffer);
  reverse(buffer.begin(), buffer.end());

  // Try finding lowercased version in the full_rules
  size_t prefix_len = 0;
  auto it = full_rules.find(buffer);

  if (it == full_rules.end()) {
    if (version >= 2) {
      string& suffix = s.words.back().misc;
      // Try searching suffix_rules if needed
      while (suffix.size() + 1 < buffer.size()) {
        suffix.push_back(buffer[suffix.size()]);

        auto suffix_it = suffix_rules.find(suffix);
        if (suffix_it == suffix_rules.end())
          break;

        if (!suffix_it->second.words.empty()) {
          it = suffix_it;
          prefix_len = buffer.size() - suffix.size();
        }
      }
      suffix.clear();
    }

    if (!prefix_len) {
      // No match
      s.words.back().form.assign(token.str, token.len);
      if (misc.len) s.words.back().misc.assign(misc.str, misc.len);
      return;
    }
  }

  // Determine casing
  enum casing_t { UC_FIRST, UC_ALL, OTHER };
  casing_t casing = OTHER;
  //enum { UC_FIRST, UC_ALL, OTHER } casing = OTHER;

  if (unicode::category(utf8::first(token.str, token.len)) & unicode::Lut) {
    casing = UC_ALL;
    for (auto&& chr : utf8::decoder(token.str, token.len))
      if (unicode::category(chr) & (unicode::L & ~unicode::Lut)) { casing = UC_FIRST; break; }
  }

  // Fill the multiword token
  s.multiword_tokens.emplace_back(s.words.back().id, s.words.back().id + it->second.words.size() - 1, token, misc);

  s.words.back().form.clear();
  if (prefix_len) {
    // Note that prefix_len is measured in byte length of lowercased characters
    string_piece suffix(token);
    while (s.words.back().form.size() < prefix_len && suffix.len)
      utf8::append(s.words.back().form, unicode::lowercase(utf8::decode(suffix.str, suffix.len)));
    s.words.back().form.assign(token.str, token.len - suffix.len);
  }
  for (auto&& chr : utf8::decoder(it->second.words[0]))
    utf8::append(s.words.back().form, casing == UC_ALL || (casing == UC_FIRST && s.words.back().form.empty()) ? unicode::uppercase(chr) : chr);

  for (size_t i = 1; i < it->second.words.size(); i++)
    if (casing != UC_ALL) {
      s.add_word(it->second.words[i]);
    } else {
      s.add_word();
      utf8::map(unicode::uppercase, it->second.words[i], s.words.back().form);
    }
}

0 个答案:

没有答案