wmmhihaa
wmmhihaa

Reputation: 953

gcc4mbed compiler issue (c++)

I have a project that compiles just fine in the mbed online compiler, but when I try to compile it localy using gcc4mbed it fails with:

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

The code segment looks like this:

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: }

Upvotes: 1

Views: 181

Answers (1)

wmmhihaa
wmmhihaa

Reputation: 953

Replacing #include <stdio.h> with #include <cstdio> solved the issue.

Upvotes: 2

Related Questions