symbol 'true' cannot be resolved?

Go To Last Post
28 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Why do I get the symbol 'true' cannot be resolved?

 

 

I've included <stdbool.h>

EDITED: This is in Eclipse.

 

 

Last Edited: Sun. Apr 7, 2019 - 07:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it is capitalized (since it is a macro): TRUE and FALSE.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stdbool.h defines the macro true.

If the message is that true is undefined,

my guess is that stdbool.h is not really #included.

More likely it was listed as a project file,

but not #included anywhere.

 

What is in the .i file?

I use -save-temps routinely.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unrelated to the question....  An easy

improvement to the speed of your code

would be to only call strlen(name) once,

store it in a variable and then pass this

value to memcmp.

 

--Mike

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 An easy improvement to the speed of your code would be to only call strlen(name) once,

store it in a variable and then pass this value to memcmp.

Wouldn't the compiler do this for you??...it can see that the function is re-used immediately, so it should still maintain the result for re-use.

Of course wondering what the compiler will do is sometimes like looking into a crystal ball (even though there really will be no question if you are willing to barf your way through all of the compiler documentation).

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nah Jim, that did not work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What OP seems to want is strcmp.

Even if he uses strcmp, OP will have the same problem with false.

 

Again: what is in the .i file?

If it contains a true, that is the problem.

stdbool.h #defines true.

If true is in the .i file, stdbool.h was not #included.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not try adding:

 

#define true 1

#define false 0

 

to the beginning of your program and see if it works?

 

If you google "  Symbol 'true' can not be resolved " and " Eclipse", what do you get?

 

This can't be the first time that this idiot worthless C error message has shown its stupid self.  How did every other Eclipse user deal with it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OP should look at the .i file .

Almost certainly OP did not really #include <stdbool.h>

 

Possibly OP #included "stdbool.h" and the compiler found a non-standard file.

 

Possibly eclipse defaults to C89 and omits the directory containing stdbool.h.

In that case, there should at least have bee a warning about not finding stdbool.h .

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Disclaimer: I've never used Eclipse so all that follows may be nonsense.

 

This looks like an IDE symbol indexing error, not a compilation error. From this stack overflow post it looks like you need to tell Eclipse where to find standard header files.

github.com/apcountryman/build-avr-gcc: a script for building avr-gcc

github.com/apcountryman/toolchain-avr-gcc: a CMake toolchain for cross compiling for the Atmel AVR family of microcontrollers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


the include file resolves when I right click on it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This almost makes it look like you have defined __cplusplus somewere along the compile line.

for some reason it then seems to think you the bool/true&false are defined already somewere else.

 

Are you also using the boolean variables in other files?

 

what happens if at the top of the file you actually add the defines of true and false.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Had the same problem a couple of day's ago while trying to compile Dean's light weight ring buffer code.  Try adding #include <stdbool.h> above your main() function.

Last Edited: Mon. Apr 8, 2019 - 01:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

allano wrote:
Try adding #include <stdbool.h> above your main() function.
He said he had in #1. That's the mystery here. The whole point of stdbool is that it's supposed to make bool/true/false "standard" !

 

EDIT: oh wait a minute. Are we saying this code would not compile or simply that it has "red squiggles"? Red squiggle generators like Naggy, VassistX, etc are notorious for being over-zealous as often they can't process conditional headers. So these may simply be false positives.

Last Edited: Mon. Apr 8, 2019 - 02:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
EDIT: oh wait a minute. Are we saying this code would not compile or simply that it has "red squiggles"? Red squiggle generators like Naggy, VassistX, etc are notorious for being over-zealous as often they can't process conditional headers. So these may simply be false positives.
I took "cannot be resolved" to imply "did not compile".

OP can tell us for sure.

My guess is that OP is wrong about #include-ing <stdbool.h>.

The symbol true would no longer be there.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Oh you are right - I think those icons in the left margin are Eclipse's standard way of annotating the source after a failed build to show where the compilation errors actually occurred. So the red squiggles really are red squiggles.

 

avr-gcc has a -H option that will list all header includes. This is it working in AS7:

 

 

The same could be applied to this compilation (assuming some form of GCC) to see exactly what headers it is finding. Maybe it is finding something called stdbool.h - just the wrong something?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry I was not more specific. 

 

I have an existing Project in Eclipse which contains a file with the main() function.  To become familiar with Dean's Light Weight Ring Buffer, I included that file (LightweightRingBuffer.h) in the existing Project's workspace and attempted a compile.  I received error message(s) that "true" (and Atomic_RestoreState) could not be found even though both #include <stdbool.h> (and #include <avr/atomic.h>) were included in Dean's  LightweightRightBuffer.h file. 

 

On a whim (to give both #includes better visibility), I included both in the main() function's file and those error messages disappeared.

 

Alan

 

P.S. I'm using Eclipse in a Windows environment.  I suspect Fianawarrior is using Eclipse in a Linux environment so I'm not sure my solution will fix his problem.

         And yes, the bug symbol in the left margin marks the location of compilation errors.  

         If an #include FILE cannot be found, the Eclipse editor will place a '?' in the left margin.

         Grayed out regions in preprocessor conditional branches indicate that they will not be included in a compile.

Last Edited: Mon. Apr 8, 2019 - 06:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi allano, I have included stdbool.h in my main file.

It's not a problem, just wish I did not have files marked that are okay.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:

Hi allano, I have included stdbool.h in my main file.

It's not a problem, just wish I did not have files marked that are okay.

 

Sorry if I'm don't understand.  You still have a  problem?

When you say "wish I did not have files marked that are okay", do you have files in the Project Explorer (left pane) which are marked even though the project compiles?  Check the Console view after your build, it might tell you of something is wrong (which might be something like the project's code exceeded the .text region of the controller.)

 

Alan

 

Edit: grammar

Last Edited: Mon. Apr 8, 2019 - 11:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wish I knew how it compiled without resolving true.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

skeeve wrote:

Wish I knew how it compiled without resolving true.

If he still has bugs in the left margin of the editor as shown in post 1, it did not successfully compile. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But it does compile and run correctly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So this was just a "red squiggles" thing then?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What usually happens with the "red squiggles" is that after correcting the problem (i.e. including <stdbool.h>), the "squiggles" will still be visible until you re-build the project.  Upon a successful compile, they go away.

 

FYI.  During code entry, if there is a syntax error, a question mark appears in the left margin. Putting focus on the question mark will provide the reason for the error. The question mark disappears when the syntax error is corrected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe try clean, then build?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:

Maybe try clean, then build?

 

 

true dat.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So that would be "rebuild" then?

 

I generally always use rebuild anyway - both for AVR/AS7 and for big_stuff/VS2017 to be sure there's no lurking unknowns from previous build history. Back when computers were slow you couldn't do this as a build god take 30..60 minutes but even for the big stuff I work on it's all done in about 5 minutes which gives me an opportunity to read Freaks ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior,

 

I ran across your problem today.  When you have a residual error indication after a build and successful compile, select the project with that problem in the Project Explorer view  with your right mouse and select Index -> Rebuild

 

If that does not work, check your Windows Preferences as described in https://mcuoneclipse.com/2012/03/20/fixing-the-eclipse-index/ to see if those settings will fix your problem.

 

Alan

 

Edit: added words in orange for clarity