gcc4mbed编译器问题(c ++)

时间:2016-04-22 10:50:32

标签: c++ gcc mbed

我有一个在mbed在线编译器中编译得很好的项目,但当我尝试使用gcc4mbed编译它时,它失败了:

MbedJSONValue.h:356:9: error: expected unqualified-id before '--' token
     int getc() {
         ^
MbedJSONValue.h:356:9: error: expected ')' before '--' token
MbedJSONValue.cpp:244:1: error: expected '}' at end of input
  }
  ^
In file included from MbedJSONValue.cpp:1:0:
MbedJSONValue.h:354:51: error: expected unqualified-id at end of input
     input(const char * first, const char * last) {};
                                                   ^
make[2]: *** [NRF51822/MbedJSONValue.o] Error 1
make[1]: *** [MbedJSONValue] Error 2

代码段如下所示:

346: class input {
347: protected:
348:     const char * cur_;
349:     const char * end_;
350:     int last_ch_;
351:     bool ungot_;
352:     int line_;
353: public:
354:     input(const char * first, const char * last) : cur_(first), end_(last), last_ch_(-1), ungot_(false), line_(1) {};
355: 
356: int getc() {
357:     if (ungot_) {
358:         ungot_ = false;
359:         return last_ch_;
360:     }
361:     if (cur_ == end_) {
362:         last_ch_ = -1;
363:         return -1;
364:     }
365:     if (last_ch_ == '\n') {
366:         line_++;
367:     }
368:     last_ch_ = *cur_++ & 0xff;
369:     return last_ch_;
370: }

1 个答案:

答案 0 :(得分:2)

#include <stdio.h>替换#include <cstdio>解决了这个问题。