New to both C++ and Platformio. New video was great and likely need to watch a few more times. I have imported a project from Arduino to Platformio and have some errors I don't understand. Even when I look up the info given I don't get it. It doesn't show below but there is a Squiggle below the >. This is the error associated with it. comparison between signed and unsigned integer expressions [-Wsign-compare]
Well for me anyway that does not give me a picture of the problem you are having. But maybe someone else can see it from the information you have given.
Do you get errors just loading the code into Platform I/O or when you go to compile? What board did you select when you set up your project? I just selected the Arduino UNO for this attempt to help.
I have put the lines you included above into my Platform I/O and just pasting them in I do not have an issue at least so far. I do not have the squiggly you mention below the ">"
I will need a little (or maybe a lot) more info to know what I should try next.
I am sort of new to Platform I/O myself, so I may wind up confusing you more than helping. Maybe some other will jump in to offer us both some assistance! 🤣
Can you provide the entire program? Maybe attach it as a file and not try to paste it into the post itself.
SteveG
comparison between signed and unsigned integer expressions [-Wsign-compare]
It's actually a fairly descriptive error message, essentially it says that the two variables you are comparing are not defined as the same type. The squiggle is saying that the error is the greater-than sign, basically, from PlatformIO's viewpoint, you're comparing apples to oranges.
PlatformIO is less tolerant of errors like these than the Arduino IDE, which in the long run will help you write better code but it can admittedly be frustrating.
But, as I can't see the beginning of the code where you defined them that's the best I can offer right now.
Can you provide the entire program? Maybe attach it as a file and not try to paste it into the post itself.
Even better, put it into the post but format it as code, not text. Which is my way of saying "check out all the new Help screens I added today" LOL.
😎
Bill
"Never trust a computer you can’t throw out a window." — Steve Wozniak
By the way, I do have 5 undefineds highlighted by Platform I/O after pasting your code snippet into my setup. And they all have the squiggles under them because they are undefined without the rest of your code.
SteveG
Well I knew the guru could help us out! 😀
And I saw that "Forum Help Menu" this morning, just haven't waded in yet.
Added Edit:
Just looked at the "How to Add Code to Your Post" help. And I never thought about the attaching the code versus pasting the code, but now that I've read that, I can see the shortfalls of doing it that way.
SteveG
Thanks for everyone's response. Here is the complete code. Haven't figure out how to post it as code yet. Much to learn still.
Greg
Here is Bill's help on embedding code in a post: How to Add Code to Your Post
Will give your code a shot now and see what I can discover.
SteveG
What are the types of the two variables analogValue & sensor_thresholds[i]?
My guess is one is signed and one is unsigned. They need to be the same.
Now all I see in the code from above when loaded into my Platform I/O is three libraries that I don't have. I'm not sure what good it would do me to load the libraries (I would guess I could if I was sure I was getting the exact same ones you have), but without the hardware setup I would not be able to go any further than a compile. Does you Platform I/O now show errors or warnings even before compiling?
SteveG
I think @gam got that corrected since when I loaded his latest code section I did not have any type mismatches.
SteveG
I think it boils down to:
uint16_t sensor_thresholds[SENSOR_N]...
int analogValue = 0;
sensor_thresholds is unsigned, while analogValue is signed.
I think @gam got that corrected since when I loaded his latest code section I did not have any type mismatches.
Sorry, I didn't realise that. Thanks.
Another option for posting code snippets is using Github gists ( https://gist.github.com/), assuming you have a Github account. It can be easier than trying to format and read bits of code in a forum topic, no offence to these forums.
Not everyone is going to have a Github account, especially if they are just getting their feet wet. So while reading the code in a "code" enhanced section of the post may be a little difficult, sometimes it may be the only option.
And the reason I said @gam may have corrected that already is that I'm not seeing the type mismatch at least with the code just sitting in my editor. Does Platform I/O have enough 'smarts' to see that, or does it really have to be compiled before we'd see that error. I have not attempted to compile as I probably won't load those missing libraries.
I do see now where the two variables aren't both either signed or unsigned!
SteveG
It's a compile time error, so you have to compile to see it. Unless it auto-compiles every time you change the file? I'm not familiar with Platformio. Eclipse auto-compiles in the background after you save a file, at least it does with Java projects. I don't know if that's true for C++.
Thanks again for your help. I thought this would be an easy question that it was just my lack of knowledge (TRUE), I didn't expect that much back and forth about what was going on. I guess I need to read up on signed and unsigned.
Thanks again
Greg