cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ Creator & Designer

LuBe_4654241
Contributor

Hi,

how can I delete these warning "typedef 'BOOL' locally defined but not used [-Wunused-local-typedefs]" with PSoc creator ?

Best regards

LuBe

 

 

 

0 Likes
1 Solution
LuBe_4654241
Contributor

Hi,

the solution is place the DataType.h on the top of source file.

Best regards

LuBe

View solution in original post

0 Likes
8 Replies
Len_CONSULTRON
Honored Contributor II

LuBe,

I placed the following line in my main.c.

typedef uint8_t BOOL;
or
typedef _Bool BOOL;

I didn't get ANY errors or warnings as you mentioned.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
LuBe_4654241
Contributor

Hi,

my situation is that on attached file.

Best regards

 

 

 

0 Likes
Len_CONSULTRON
Honored Contributor II

LuBe,

I moved my typedef of BOOL into a header file called datatypes.h.  Still no warnings about a locally defined but not used.

It must be how your project is configured.

Please supply the following window shot of the "Build Settings/ARM xxx/Compiler/Command Line"

Len_CONSULTRON_0-1623073627411.png

We can use this to understand what compiler settings you are using.

 

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
LuBe_4654241
Contributor

Hi,

the compiler settings are these:

Compiler settings.JPG

I am using theCypress  project named CE195313 that you can use for test.

Best regards

LuBe

 

 

 

 

 

0 Likes
Len_CONSULTRON
Honored Contributor II

LuBe,

I believe I have your answer.

The warning comes up because the compile option "-Wunused-local-typedefs" is used.  Although you don't directly enable this option the option "-Wall" is used and this enables this option.  Here is an excerpt from the "GCC command options" (Chapter 3 pg 79)

 -Wunused-local-typedefs (C, Objective-C, C++ and Objective-C++ only)
Warn when a typedef locally defined in a function is not used. This warning is
enabled by ‘-Wall’.

Notice the text I highlighted in RED.

I don't get the warning if I place the typedef for BOOL -OR- if I #include the datatypes.h file outside of a function.

Once I place the typedef -OR- #include the datatypes.h file INSIDE a function, I get the warning.

Solution:  A typedef should usually be global to the project.  Place your include for datatypes.h near the top of the .c file outside any functions.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
LuBe_4654241
Contributor

Hi,

the solution is place the DataType.h on the top of source file.

Best regards

LuBe

View solution in original post

0 Likes
odissey1
Honored Contributor II

LuBe,

Cypress ha pre-defined CY_BOOL definition, which boils down to uint8

CY_BOOL myFlag=0;

0 Likes
Len_CONSULTRON
Honored Contributor II

There also _Bool.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes