2016-04-22 16 views
1

Ich habe ein Projekt, das in dem mbed Online-Compiler gerade fein kompiliert, aber wenn ich versuche, es zu kompilieren localy gcc4mbed Verwendung es nicht mit:gcc4mbed Compiler Ausgabe (C++)

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 

Die Code-Segment sieht dies wie:

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

Sollte mit Ihrem Problem nicht verwandt sein, aber das Semikolon nach der Konstruktordefinition wird nicht benötigt. –

+0

@JoachimPileborg Danke, hättest du vielleicht eine Idee, wie man gcc4mbed mit den gleichen Optionen wie mbed online kompiliert, oder ob es eine Alternative zu gcc4mbed gibt? – wmmhihaa

Antwort

2

Ersetzen #include <stdio.h> mit #include <cstdio> löste das Problem.