Codewarrior for CF bool support

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Codewarrior for CF bool support

3,449 次查看
Neilp
Contributor I
Hi all.

In Codewarrior for Coldfire V6.4 SE, I can't seem
to get the compiler to understand the bool data type.

I have the following declaration:


Code:
bool rc5_detect(void);

 

which produces the following error:

Error  : undefined identifier 'bool'
irlearn_routines.h line 2 bool rc5_detect(void);

I have 'Enable bool support' checked in the language settings,
and the keyword appears in blue in the editor, suggesting that
it is recognized as a keyword.

I don't know if any other header files need to be included, as
bool is a language keyword, is it not?

Does anyone know what I might be doing wrong?

Regards,
Neil.
标签 (1)
0 项奖励
回复
2 回复数

1,266 次查看
CompilerGuru
NXP Employee
NXP Employee
With C99,
you have to include
#include <stdbool.h>
for bool to be known.
In C89, there is no bool type, you can typedef your own, of course.
In C++, bool is builtin, but the C++ support needs the professional license.
I'm not sure what the "Enable bool Support" preference exactly does, but I fear it enables the C++ bool support which then does not get enabled because of the C++ licensing issue.

Daniel
0 项奖励
回复

1,266 次查看
Neilp
Contributor I
Thanks for the info Daniel.

If I #include <stdbool.h> I get:

Warning : preprocessor warning directive
stdbool.h line 20 #warning "MSL support for C99 is not enabled"

As a result, bool is still not understood.

Going into the language settings panel and checking "Enable C99
Extensions" once again does nothing to fix the warning.

What I did try was to goto  C:\Program Files\Freescale\
                            CodeWarrior for ColdFire V6.4\
                            E68K_Support\msl\MSL_C\MSL_E68k\
                            Include\

and edit ansi_prefix.CF.size.h and then change
#define _MSL_C99 from 0 to 1.

This fixes the problem, but my question is, is it safe to edit
this file. I don't want to mess anything up down the road.

Of course, like you say I could typedef my own, which I suppose
would look like:

Code:
typedef unsigned char bool;#define  FALSE  0#define  TRUE   1
 

Regards,
Neil.
0 项奖励
回复