grown man crying - compiler errors

Last week I came for help with a large (not my) sketch and got some wisdom about the behaviour of the pre-processor. I was able to get back on track.

Imagine my distress when, as far as I can remember, I get out the same program to do a bit more work on it and am newly met with reams of errors like

hubsan:11: error: 'hubsan_init' was not declared in this scope

Now I certainly understand the message - this is a sloppy program relying on hidden agendas. What I do not understand is what tiny innocent change I might have made to make these errors, well, errors, where just recently they flew fine.

I know that a first error can make a subsequent cascade of spurious errors, but I find no error I might have introduced to do so.

I know I must have done more than get out the sketch from last time, when it compiled just fine! It bears a comment 'changed only so it will compile', which it did. But I must have touched some super sensitive nerve.

I could carefully fix this sketch to have proper declarations in all the right places. My confidence that doing so would resolve the (real?) problem is low, as is my time and patience for doing.

It almost feels like a missing tab, or one that isn't being considered. Or a global switch for, I don't know, lazy easy forgiving compilation vs. strictly by the book.

I would appreciate an idea of where I might best spend my time on this - right now I probably should be... skiing. :slight_smile:

Look only at the FIRST error message. Fix that, then re-compile and, if necessary, repeat.

Regards,
Ray L.

(deleted)

Thank you, yes. I understand the approach.

In this case it seems to be a id10T thing, a PEBKAP thing… despite it being the very definition of insanity, I applied the same fixes I learnt about last time to the original sketch and… it compiles.

Leaving a mystery as to what teeny change took me off task and made me run crying for help. Can't believe it is dependent on the ambient temperature although that is what it feels like.

If I have time, I will try to see where I went wrong (this time), as it has happened before and no doubt will.

Talking to myself: find a coherent explanation of what and how the Arduino IDE does its thing, in particular how it differs from "real" programmer's IDEs and ideas… step up and learn it.

spycatcher2k:
Would it be too much for you to post the code and links to any libraries used? Your question is like calling a mechanic and saying 'my car makes a funny noise - tell me whats wrong' - what questions would he probably ask?

Too much to ask of you all! This is more an issue of my refusal to internalize what I consider to be some very odd and variously helpful/non-helpful pre-processor or compikler behaviour.

As I said, it is a large sloppy (not my) sketch that compiled just fine several years ago and is now throwing me curves all over the place. So I am looking at not the code, but the environment and what changes might have been wrought that disenfranchise the sketch.

The last problem I baked down to a tiny sketch and learned (or was shown at least) some subtleties that I must just wrap my head around or this kinda thing will keep biting me.

ARGH!

I cannot believe this I am ready to find a tall building and jump off it.

I have done and undone a change which moves the sketch from 'compiles to doesn't'.

Adding a comment about the (good) work I've done sends me off the rails.

// This file makes the Arduino IDE happy (directory name must match a *.ino file).
// Code is in all other files.

// this did bind to the Hubsan X4 H107L.

// see myA7XShouting.txt

// is there such a thing as overrun?
// HARD CODED channel 0x50 everywhere
// THIS DOES single packets between two instances!

// now add - PB0 asserted on reset means listen always and ack after a delay any received meesages
// without discrimination, this should set up a pinging pong.

// starting to strip out some of the Hubsan stuff...

/*
was successful ping-pong unit program
now this section will model the hand-rolled ack pack
then both will try it, here's where I'll add the prime table.

milliseconds?
*/

All comments. Adding one more /* comment */ at the top is a problem. Why?

Adding a // comment is a problem
Adding blank lines is a problem

I am sitting here doing and undoing absolutely innocent changes to the tab above… and going from compiles to doesn't.

There has to be something I am missing?!

Would it be too much to ask you to post some code that demonstrates the problem ?

(deleted)

even if your code has not changed, any or all of your imported include files and/or libraries may have.

alto777,
so far, no code has been posted, so we haven't actually seen any issues.

Remember that we have to actually see the issues and potentially even be able to re-create them to be able to help you solve them.
It can be IDE related as there was a change that the arduino guys did when things moved to 1.0 that broke 100% of all the existing libraries. Then there are a few IDEs that are so bad that you literally should not even attempt to use them as they have all kinds of issues that can create very strange issues and errors that can occur on perfectly valid code.
So if you were using an older IDE but now using a newer IDE then depending on the IDE versions, there may be an IDE issue involved.

If you want help, then post your code and tell us what Arduino board and what version of the IDE you were and are now using along with any libraries being used.
These details are very important to be able to provide assistance.
Otherwise, this is thread is not much more than just whining and/or complaining.

--- bill

Well I certainly appreciate your point of view. I did post the tab which is the only area where I am making the changes that are causing the difficulties of the moment.

I am literally able to make changes in that tab alone and go from compiling to not compiling. Adding THREE BLANK LINES to a tab which has only comments in it in the first place.

Removing the blank lines puts me back on the air.

Forgive me if I suspect it is not libraries, not syntax, not typos - not anything can think of! I may not know what I am doing (!), but this is beyond bizarre.

I can only conclude that the cause is without the Arduino IDE, some how. So never mind! But thanks for the attention.

I will carry the whole sketch to another computer and see if the gremlins have been left behind. Speaking of gremlins, I did in fact look at the text file in the hope of finding some oddball non-printing character. No dice.

I've worked larger sketches and I don't think there are limits I am bumping up against. As I said, this is most likely something deeply mysteriously wrong happening coincidently and unrelated to the IDE. It is unlike anything I have come across!

alto777:
I will carry the whole sketch to another computer and see if the gremlins have been left behind. Speaking of gremlins, I did in fact look at the text file in the hope of finding some oddball non-printing character. No dice.

I've worked larger sketches and I don't think there are limits I am bumping up against. As I said, this is most likely something deeply mysteriously wrong happening coincidently and unrelated to the IDE. It is unlike anything I have come across!

Several of the IDEs screw up parsing the sketch file when attempting to convert it to compilable C++ when creating the .cpp file. (even when the code is perfectly valid code) A few IDEs are so bad that you shouldn't even use them.
The only way to really know is to simply look at the .cpp file generated by the IDE rather than just keep trying somewhat random things.

All this trial and error type of guesswork is a very ineffective way of trying to resolve the issue, particularly when you have people right here who could likely answer your questions and help resolve your issues if you only would provide the information that was being asked for.
But hey, at least it is your time not ours....

My recommendation would be to run a very recent IDE like 1.6.10 or newer as most of the sketch to .cpp file issues have been resolved.

--- bill

If you get errors when compiling there will be a "copy error message" button in the console window below the code window, click that and at least post that between [code] [/code] tags, if you don't want to post your code. It will look like this:

Arduino: 1.6.5 (Linux), TD: 1.28, Board: "Arduino Nano, ATmega328"

correctmils_2.ino: In function 'void setup()':
correctmils_2:14: error: 'XXXbtnPin' was not declared in this scope
'XXXbtnPin' was not declared in this scope

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Thank you for the suggestions. I tracked down the files that the preprocessor makes and present here the two versions.

My problem seems to be sensitive to the NUMBER OF BLANK LINES I insert as they push something past a point in a multi-line C-style /* comment */ where the preprocessor decides to start talking about the next tab, the first tab with any code in it.

See for yourselves: I attach the concatenated *.cpp files in the two instances.

In both versions stuff from the second tab appears within stuff from the first tab - I just get lucky when it isn't inserting things into the middle of a comment.

In the working instance, I get all the code. In the non-working instance, much of the code in the next tab is effectively /* commented out, no wonder causing many errors. It's easier to see with an editor that colors the comments.

Short fix and for the future, mine anyway: don't use multi-line /* */ comments.

Here's the main tab verbatim except the line marked *****>>, which shows where the blank lines cause a problem.

// This file makes the Arduino IDE happy (directory name must match a *.ino file).
/* add a comment */
// Code is in all other files
*****>> if this is one blank line, fine. If four blank lines, the problem crops up...
// this did bind to the Hubsan X4 H107L.

// see myA7XShouting.txt

// is there such a thing as overrun?
// HARD CODED channel 0x50 everywhere
// THIS DOES single packets between two instances!

// now add - PB0 asserted on reset means listen always and ack after a delay any received meesages
// without discrimination, this should set up a pinging pong.

// starting to strip out some of the Hubsan stuff...

/* add a comment */
/*
was successful ping-pong unit program
now this section will model the hand-rolled ack pack
then both will try it, here's where I'll add the prime table.

milliseconds?
*/


/* add a comment */

I attach the two concatenate files - the second was from adding three blank lines to the above.

I have googled and see Different compilation with comments / ** / multiple lines · Issue #1293 · arduino/Arduino · GitHub - I think something similar is happened here.

I understand that it is not usually fruitful to look for this kind of error. Believe me I make plenty of errors and can usually fix them through the kind of logical process you are recommending. Any experimentation I did was in an effort to make the smallest sketch possible that shows the problem - I think I may be able to do that now. Or tomorrow that is.

concatenate1.cpp (31.7 KB)

concatenate2.cpp (31.7 KB)

For me, with v1.6.5, it produces exactly what I'd expect - unresolved reference to setup() and loop(). The number, or contents, of comment lines makes no difference whatsoever.

Regards,
Ray L.

Which version of the Arduino IDE are you using? As bperrybap said, some versions of the IDE had these sorts of issues but in the recent versions the known bugs have been fixed so if you're not using the latest version you may be encountering a problem that's already solved. I recommend using Arduino IDE 1.6.13, which has been a pretty good release.

pert:
in the recent versions the known bugs have been fixed

I wouldn't go that far. There are several things that even the latest IDE still barfs on.
I've tracked down and reported many IDE mis parsing & mis inserstion of prototype issues over the years and while most have been fixed, there are still some that remain that require tweaking your perfectly valid code to prevent the IDE from screwing up.
I tend to see quite a few IDE issues as I maintain a very complex library that runs on many different IDE versions from pre 1.0 all the way to the latest 1.6.13 and it also runs on many different cores (AVR, ARM, pic32, ESP8266)
I just ran into another new one today that relates to explicitly checking for library header guard defines in a sketch.

With respect to what alto777 is experiencing, there is no telling since he refuses to provide the full code or to even supply basic information such as what version of IDE or what core is being used.

Until I see all the requested information, I'm dropping out of the conversation.

--- bill

alto777:
Well I certainly appreciate your point of view. I did post the tab which is the only area where I am making the changes that are causing the difficulties of the moment.

We keep telling you that we need to see all the code, and you keep replying "no, actually you don't". If you are so certain that everyone here doen't know what they are talking about - why come here to ask for advice?

alto777:
I am literally able to make changes in that tab alone and go from compiling to not compiling. Adding THREE BLANK LINES to a tab which has only comments in it in the first place.

My guess - those blank lines you are adding aren't actually blank. There is some dodgy unicode going on.

Fair enough all! Here's the whole thing zipped up.

In the first tab apUNI8a, see the line

// ADD TWO BLANK LINES AFTER THIS LINE and it breaks. 1.6.13

add two blank lines after that comment and it breaks. For me. I'll be trying on another machine just for the thoroughness of it.

TIA, I truly appreciate the effort you might go to here.

apUNI8a.zip (12.3 KB)

Code compiles here after removing the static keywords from hubsan.ino.

Initial error; using IDE 1.6.6 as shown

Arduino: 1.6.6 (Windows 8), Board: "Arduino/Genuino Uno"

...
...
C:\Users\sterretje\Downloads\arduinoforums\topic=442502.15\apUNI8a\apUNI8a\hubsan.ino: In function 'void initialize()':

hubsan:8: error: 'void initialize()' was declared 'extern' and later 'static' [-fpermissive]

 static void initialize() {

                        ^

a7105:35: error: previous declaration of 'void initialize()' [-fpermissive]

   // set GIO1 to SDO (MISO) by writing to reg GIO1S

      ^

hubsan:80: error: 'void update_crc()' was declared 'extern' and later 'static' [-fpermissive]

 static void update_crc()

                        ^

a7105:37: error: previous declaration of 'void update_crc()' [-fpermissive]

   A7105_WriteReg(0x0b,0x19); // 0b011001

      ^

Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI 
exit status 1
'void initialize()' was declared 'extern' and later 'static' [-fpermissive]

Even after adding empty lines in apUNI8a. Might be more interesting to see the code with the additional lines in apUNI8a that does not compile on your system.