Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong insertion of function prototypes converting .pde to .cpp #140

Closed
gandy92 opened this issue Mar 25, 2015 · 3 comments
Closed

Wrong insertion of function prototypes converting .pde to .cpp #140

gandy92 opened this issue Mar 25, 2015 · 3 comments
Milestone

Comments

@gandy92
Copy link

gandy92 commented Mar 25, 2015

Automatic insertion of function prototypes fails in some cases, for example:

The file src/DCFBinaryStream.pde containing

#include <DCF77.h>       //https://github.com/thijse/Arduino-Libraries/downloads
#include <Time.h>        //http://www.arduino.cc/playground/Code/Time

#define DCF_PIN 2                // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0          // Interrupt number associated with pin

time_t time;

// [...]

void digitalClockDisplay(time_t _time){
  tmElements_t tm;   
  breakTime(_time, tm);
  // [...]
}

is converted to .pioenvs/autogen_pro8MHzatmega328/src/DCFBinaryStream.cpp

#include <Arduino.h>
void setup();
void loop();
void digitalClockDisplay(time_t _time);
void printDigits(int digits);
#line 1 "DCFBinaryStream.pde"
#include <DCF77.h>       //https://github.com/thijse/Arduino-Libraries/downloads
#include <Time.h>        //http://www.arduino.cc/playground/Code/Time

#define DCF_PIN 2                // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0          // Interrupt number associated with pin

time_t time;
[...]

which leads to the compiler error

.pioenvs/autogen_pro8MHzatmega328/src/DCFBinaryStream.cpp:4:26: error: variable or field 'digitalClockDisplay' declared void
void digitalClockDisplay(time_t _time);
^
.pioenvs/autogen_pro8MHzatmega328/src/DCFBinaryStream.cpp:4:26: error: 'time_t' was not declared in this scope
DCFBinaryStream.pde: In function 'void loop()':
DCFBinaryStream.pde:39:30: error: 'digitalClockDisplay' was not declared in this scope
scons: *** [.pioenvs/autogen_pro8MHzatmega328/src/DCFBinaryStream.o] Error 1

The correct solution would be to define the prototypes at the latest possible point, most impportantly after the include directives (which however could be anywhere in the source).

Another solution would be to move the #include statements to the top, introducing the difficulty of correctly handling include statements within #ifdef/#ifndef blocks.

@ivankravets ivankravets added this to the 1.3.0 milestone Mar 25, 2015
@ivankravets
Copy link
Member

Sorry, I will work on it today and fix it. I've marked your issue as duplicate of #137

@gandy92
Copy link
Author

gandy92 commented Mar 25, 2015

Sorry for placing a duplicate, I completely missed #137

@ivankravets
Copy link
Member

Fixed in f800b35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants