<stdbool.h> doesn't work ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

<stdbool.h> doesn't work ?

979 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveNadler on Sat May 14 11:31:42 MST 2011
[FONT=Arial]Hi - I tried to use type "bool" (using LPCXpresso v3.6.3):
[/FONT][INDENT][FONT=Fixedsys]#include <stdint.h>
[/FONT][FONT=Fixedsys]#include <stdbool.h>
[/FONT][FONT=Fixedsys]bool bools__dont_work;[/FONT]
[/INDENT][FONT=Arial]I got the following error:
[/FONT][INDENT][FONT=Fixedsys]../src/main.c:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'bools__dont_work'
[/FONT][/INDENT][FONT=Arial]Investigating the include shows:
[/FONT][INDENT][FONT=Fixedsys]#if !defined(__CR4_STDBOOL_H__)
[/FONT][FONT=Fixedsys]#  define __CR4_STDBOOL_H__
[/FONT][FONT=Fixedsys]#  if defined(__REDLIB__)
[/FONT][FONT=Fixedsys]#    include_next <stdbool.h>[/FONT]
[/INDENT][FONT=Arial]Eclipse (and I) are confused by "include_next".

What am I doing wrong ?
Thanks,
Best Regards, Dave


g[/FONT]
0 Kudos
6 Replies

767 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveNadler on Mon Oct 17 05:42:19 MST 2011
[FONT=Arial]Thanks CodeRed for fixing this in version 4 - much appreciated,
Best Regards, Dave
[/FONT]
0 Kudos

767 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Sun May 15 10:08:32 MST 2011
Hi Dave,

I knew you had the experience to circumvent the problem, others may not.


Quote: DaveNadler
[FONT=Arial]...it is after all already 2011 last I checked...[/FONT]

[FONT=Arial]Thanks especially for the [/FONT][FONT=Arial]GNU [/FONT][FONT=Arial]link !  I really enjoyed this part:[/FONT]
[INDENT][I]The use of `#include_next' can lead to great confusion.  We recommend it be used only when there is no other alternative.[/I]
[/INDENT]



I thought you would notice that.:)  It's a kludge fix that should have been done away with a long time ago.

CodeRedSupport should take notice of this because it obviously doesn't drill down to the next directory, newlib, as it implies and should.  It is indeed broken in this case.

Larry
0 Kudos

767 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveNadler on Sun May 15 09:53:07 MST 2011
[FONT=Arial]Thanks all for the replies. Certainly I know how to work around this, I was hoping it wasn't necessary, it is after all already 2011 last I checked...
Thanks especially for the [/FONT][FONT=Arial]GNU [/FONT][FONT=Arial]link !  I really enjoyed this part:
[/FONT][INDENT][I]The use of `#include_next' can lead to great confusion.  We recommend it be used only when there is no other alternative.[/I]
[/INDENT][FONT=Arial]Thanks again,
Best Regards, Dave
[/FONT]
0 Kudos

767 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Sat May 14 14:42:57 MST 2011
If you are still wondering about the include_next look at this:

http://gcc.gnu.org/onlinedocs/cpp/Wrapper-Headers.html
0 Kudos

767 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sat May 14 14:27:39 MST 2011
Redlib implements C90, whereas stdbool.h is part of C99. If you want a C99 level C library you will need to use Newlib (or in this case, simply provide your own implementation of the stdbool.h header).

More information at:

http://support.code-red-tech.com/CodeRedWiki/RedlibAndNewlib

It is probably worth adding that we are looking at extending the functionality provided by Redlib. Thus future releases of LPCXpresso will start to provide more C99 functionality (including stdbool.h).

Regards,
CodeRedSupport.
0 Kudos

767 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Sat May 14 12:59:21 MST 2011
Hi Dave,

I don't have an answer for why it doesn't work, but I do have a workaround.

Just add these to your source file:

#define  bool  _bool
#define true 1
#define false 0

or:

Grab the stdbool.h from here: (If your using Linux you will have to find where it is.)  C:\nxp\lpcxpresso_3.6.3_317\Tools\lib\gcc\arm-none-eabi\4.3.3\include\newlib

Copy and paste it into your projects source or include directory.  Change the include <stdbool.h> to include "stdbool.h"

I just tested both methods and they worked for me.  CodeRedSupport can answer your question later.

Larry
0 Kudos