Pages: 1 [2]   Go Down
Author Topic: Compiler bug?  (Read 1235 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 615
Posts: 49388
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use File + Preferences to turn on verbose output. Find the temporary directories where compilation actually takes place. Delete all of them. Then, try compiling again. Does the commented out #include of SoftwareSerial still generate issues?

Even if it does, it is NOT a compiler issue. It is an IDE issue. Look in the build directory. Is SoftwareSerial.cpp and SoftwareSerial.h there? They would not be if the IDE was working correctly.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have verbose outup ON still...

When I open NEW project and insert into this new code test3.pde from bperrybap - I still get error when I select Arduino MEGA8 board...

So what can I test now? I use arduino 1.0.2 .... I go to test it in newer 1.0.3 IDE... But I think it is some IDE bug :-(
Logged

Dallas, TX USA
Online Online
Faraday Member
**
Karma: 67
Posts: 2707
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have verbose outup ON still...

When I open NEW project and insert into this new code test3.pde from bperrybap - I still get error when I select Arduino MEGA8 board...

So what can I test now? I use arduino 1.0.2 .... I go to test it in newer 1.0.3 IDE... But I think it is some IDE bug :-(

I explained how it works. (I don't like how it works either)
The IDE looks for certain include files or objects to be referenced. If it sees those, the IDE
 includes the library associated with those header files or objects in the build.
The IDE analyzer is too simplistic and does not understand conditional compilation.
When you really do comment out the includes in your sample code yes it does compile even for Atmega 8.
I commented out include for SoftSerial and it compiles just fine.

The file I used with the commented out include is attached.

The reason it works when you changed the name of the include is that the IDE is no longer
recognizing that header as part of the SoftSerial library and so it is no longer trying to pull in
the SoftSerial library.

Again, the issue is the IDE and it's simplistic internal preprocessor that looks for
Arduino libraries and objects in an attempt to fix up the user sketch code.
If it recognizes what it considers to be Arduino headers or objects related to Arduino libraries,
it will build and link against the associated library.
It does not understand conditional compilation and that is where you are having issues.

The way the IDE works today, you can not use a conditional to selectively include an arduino library.
The IDE will trigger on seeing the library header or object regardless of whether it is inside
a disabled conditional.

--- bill

* test3.pde (1.04 KB - downloaded 7 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found source of problem -
Arduino IDE treated differently to each method of commenting.
when I close include directive to /* as comment - IDE ignore this comment symbol and read this line as normal.
when I use // before line - IDE don´t compile it. It´s not good IMHO. /* block and // is too same and compiler (Arduino IDE) must respect both of this comments methods.
If is accepted only one way, it can lead to unpredictable behavior.

I think it could be proposed as a fix for the next version of ide.
What do you think about it?
Logged

Dallas, TX USA
Online Online
Faraday Member
**
Karma: 67
Posts: 2707
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting.
You should definitely enter a bug report for it into the issues list.

I tried using /* */ all on the same line and the IDE does recognize this
as commenting out that line.

In the larger picture, in my opinion, the IDE does lots of silly stuff.
The build methodology of trying to parse the file for libraries and referenced objects
has tons of problems.
I've even had it barf on code that is perfectly valid C code and crash the IDE.
Those are very hard to track down and the only option is to move some of your code around
to different lines until it works again.


In your case since you seem to be using the SoftSerial for output only,
I'd go in and create a new SoftSerial "library" that does non interrupt driven  output only - the output routines
can be much simpler than the input routines as there are no interrupts.
It doesn't even have to be a real Arduino library.
Take the SoftSerial library code, crush it down and rip it apart
and put all the code and new class definition in a single header file.
Then, you can use your debug ifdefs to include the header file for
your SoftSerialDebug class (library) and do what you originally wanted to do.

--- bill


Logged

Pages: 1 [2]   Go Up
Jump to: