Wunused-local-typedefs

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LuBe_4654241
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

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

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
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

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
lock attach
Attachments are accessible only for community members.

Hi,

my situation is that on attached file.

Best regards

 

 

 

0 Likes

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

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

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

Hi,

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

Best regards

LuBe

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

LuBe,

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

CY_BOOL myFlag=0;

0 Likes

There also _Bool.

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