Go Down

Topic: Compiler bug? (Read 1 time) previous topic - next topic


This no help :-(

Code: [Select]

static char stupidIDE;

This will trick/force the IDE into placing its header file correctly into your working
temporary file and since your code is not referencing the dummy variable, the linker will remove it.

---- bill


I understand everything if I use only IFDEF procedure...

But when I comment whole block as I post at top, I don´t know why IDE can not ignore it and still using this commented lines...

Only when I corrupt name of include - Sxxxrial - now IDE ignore it... It´s very bad :-(

But you didn't comment out everything in the code example in your first post.
This was in that code:
Code: [Select]
//#define DEBUG    // Debug ON (this switch on software serial)                    DEBUG 1/2 !!!!
#ifdef DEBUG
#include <SoftwareSerial.h>

The #include is not commented out.
It is inside a conditional compilation block controlled by the define DEBUG but that is not a comment.
While the compiler understands conditionals, the IDE does not.

The IDE saw the include for the SoftwareSerial header and
assumes a reference to SoftwareSerial and so it decided to help you out by
including the library for you as part of the build.
(The IDE tells the compiler what to compile and the linker what to link)

The errors I saw from your compilation were not related to this.
They appeared to be related to the IDE incorrectly inserting its "Arduino.h" header and prototypes

Attached are examples of how the IDE creates your .cpp file with/without the dummy variable declaration
at the top of you code.
When including header files and especially when doing any conditional compilation, it is usually mandatory
to add this dummy variable to the top of your sketch code because the IDE can often drop its header include
and declarations in a bad location rather than at the top where it needs to be.

To avoid the IDE issue of incorrectly inserting its header and prototypes, I always declare
a dummy static variable at the very top of all my code that is used with the Arduino IDE.

--- bill


This no help :-(

Your example code from your initial post (cleaned up a little) compiled just fine for me.
(I had to correct a few things).
It is a attached.

--- bill


Do you compile it for ATMEGA8 ? when I compile it for UNO, everything is ok - atmega8 cannot accept software serial so for this reason make error. This is why I found this error. When I use UNO, I can not see when software serial is compiled. it is silent.

My first code i WRONG !!! I compile it with my second code in middle of this topic.
When I use IFDEF, I can hope IDE use include directive.

But I use this :
Code: [Select]

//#define DEBUG    // zapnout LADENI (zapne software serial)                    DEBUG 1/2 !!!!
//#ifdef DEBUG
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(11, 12); // RX, TX
// if DEBUG, MUST be uncomment   

and still I GET error about software serial, which IS COMMENTED .....

You must select arduino board : Arduino NG or older w/ Atmega8.... UNO work super with softwareserial and you can not find this error...


But it is not error in header files, libraries etc... it is Arduino IDE error.. When i change commented line with
Include softwareserial to Include xxxserial - now everything is ok.... Now arduino dont send error about software serial and dont compile software serial.

Go Up