What line is the error in? Web IDE and Spark Dev don't show

Hello,

I am trying to port some code from Ardunio to Spark and I am using the web IDE. I am getting the “Error: could not compile. please review your code.” message. Is there any way to find out in what line this is happening?

Thanks
Markus

Can you show your code?

This message sometimes occures when the compiler can’t even start building for some reason and therefore can’t tell you what’s wrong and where.

Cant show the code here - it is very long and spread over several files.
I just used the Spark Dev app and get “App code was invalid” error. Is there any compile output anywhere?

If you can’t show it here you might be able to post a Gist or Dropbox link for someone to download and try it on a local toolchain - or you install a toolchain locally and try it yourself.
You could also show a screenshot of your Spark Dev/Web IDE error report (have you tried clocking on the (i)nfo / <!> exclamation or other error indicator?)

I cleaned out all unused files in my directory and now I get a first meaningfull error message: ‘flash-eeprom/flash-eeprom.h’ no such file or directory.

Hi @MarkusL,

Sorry about that! The compiler tries to show line numbers whenever possible, but there are a few cases where the error isn’t limited to a particular line, and might encompass one or more files. In this case the errors aren’t particularly helpful, and is something I’d like to improve. Please let me know if there was a specific cause behind that general error, and I can try to fix that case.

Thanks!
David

1 Like

I am trying to use the EEPROM library but both fail:

> #include "flash-eeprom/flash-eeprom.h"
> #include <flash-eeprom/flash-eeprom.h>

Any suggestions?

Hmm, it looks like it can't find that library, did you include it in your app? I'm seeing some errors along the lines of:

helper_lib.cpp:2:39: fatal error: flash-eeprom/flash-eeprom.h: No such file or directory 

I guess I am missing something here, how do I include it other than using #include ?

Hi @MarkusL,

Oh, good question! There’s a guide here that can help:

http://docs.spark.io/build/#flash-apps-with-spark-build-using-libraries

Thanks,
David

Thanks for the link - that seem to be the process using the web IDE. I am using the Spark Dev app now.
It there a complete example showing the usage of libs with the app?

Hi @MarkusL,

If you’re using Spark Dev, then you’ll need to download the library files and include them with your project. I’m not aware of a guide for that yet as far as I know.

Thanks!
David

@MarkusL Hi there! So you are using Spark Dev also. If I am not wrong about this. App code was invalid could be cause if there are other files in the very same folder as your .ino file.

  1. So you might have to create a new empty folder and place your .ino file inside the Spark Dev is quite picky on this. Below is another thread that people, including me, faced the same problems.
    Spark Dev: app code was invalid - #15 by Leonardo - Cloud - Particle

  2. If you have libraries that you need to use that are only available in the Web IDE. Open those files you need and do a copy and paste on to a blank notepad and save it as it's respective type. (Examples like .h or .cpp For your case flash-eeprom.h) Then put this files in the same folder as your .ino file. :smile: Then in your .ino file, just simply put a #include "flash-eeprom.h" and it should be working.

Hope this helps :smile:

1 Like

There is an even easier way to do that.
If you click on the Git symbol next to the library header you get forwarded to the lib repo where you can download the zipped library at once.

1 Like

Since the topic stated that you used Web IDE, Dave gave you the answer for it :wink:
Since you migrated to Spark Dev, I took the liberty to alter your topic title accordingly - hope you don't mind :wink:

1 Like

Yes, thanks. I have used that download link but there are 2 issues:

-in the zip are more files than just code and it looks like I need to clean them out - minor problem :smile:
-It does not seem to be possible to organize the code other than putting all files into the same directory.

For example am I using the OneWire.h lib and I was not able to create a folder called “OneWire” and put the lib inside.
I get an error using #include “OneWire/OneWire.h” to include the lib.

How can that be solved?

At the moment there is no way around this, but it’s on the ToDos.

One cause of the strange error “Error: could not compile. please review your code” seems to be the browser. I am now compiling the same code in the WEB IDE on a mac and on linux and in Safari I get a nice window with the error messages but not on linux

@Dave
you seem to be able to look into the WEB IDE, I am now getting an error which baffles me:

ups_controller_v3.cpp:44:1: error: expected unqualified-id before 'else'
else if(inSync);
^
make: *** [ups_controller_v3.o] Error 1

the mentioned line (44) does not match with what is printed as the code fragment.Here is the code around that error, all symbols are defined:

bool checkSync()
{
    bool inSync = currStates.inSync;
    int diff = abs(cityZeroCrossTime - inverterZeroCrossTime);
    if(diff > 16)
        ; // next phase
    else
    {
        if(abs(cityZeroCrossTime - inverterZeroCrossTime) < 2)
        {
            inSync = true;
        }
        else
            inSync = false;
    }

    //    bool before = currStates.inSync;
    if(currStates.invFail != _OK_ ||
            currStates.cityFail != _OK_ || invRELAY == LOW)
    {
        //        digitalWrite(syncPin, LOW);
        currStates.inSync = false;
    }
    else if(inSync) //### here is the error
    {
        //        digitalWrite(syncPin, HIGH);
        if(currStates.invFail == WARMUP
                || currStates.invFail == COOLDOWN
                || currStates.invFail == FAIL_COOLDOWN
                )
            currStates.inSync = false;
        else
            currStates.inSync = true;
    }
    else
    {
        //        digitalWrite(syncPin, LOW);
        currStates.inSync = false;
    }
    return currStates.inSync;
}

Since I can’t see all your definitions the following question might be useless.

Is invRELAY a field of some struct/class or a global var?

If you gave the line numbers (in comments) it would be easier to analyse, too.

Since the error uses the term before 'else' the line number may not actually refere to the else line.


Narrowing down unclear error messages could be done by commenting out, bit by bit till the error disappears - it would be good practice to do first.