2

I am working with little endian processor PIC 32 and am looking at a variable that is of type BOOL. One variable is initialized to TRUE and the other as false.

static BOOL A = TRUE; BOOL static B = FALSE; 

In Memory when I look in memory for variable A, it shows 32 bit TRUE

It looks like the processor just assigns a 32 bit number for true and false and not 8 bits so that means its processor dependent. For an array of 6 elements of type BOOL, all set to TRUE. How would it be read? Is it going to show up as 6 elements of what is shown in the picture above?

6
  • 1
    Why not try it? Commented Jul 5, 2017 at 21:48
  • How do you know it allocates 32-bits? That looks like an 8-bit bool followed by three other things that are zero, like B being false. Commented Jul 5, 2017 at 21:48
  • Is is C standard and implementation dependant Commented Jul 5, 2017 at 21:58
  • 2
    C doesn't define a type BOOL. It defines _Bool, and stdbool.h defines bool. What does your BOOL typedef look like? Commented Jul 5, 2017 at 22:00
  • Although you are allowed (at the moment) to write int long unsigned const long static u = 23;, you shouldn't do that. Interestingly, GCC 7.1.0 when run with -Werror -Wold-style-declaration doesn't allow it: error: ‘static’ is not at beginning of declaration [-Werror=old-style-declaration]. (And -Wextra includes -Wold-style-declaration (at least in GCC 7.1.0), so you don't have to add it separately.) Commented Jul 5, 2017 at 22:21

1 Answer 1

4

BOOL is not a standard type. Depending on how it is defined in your environment, probably via a typedef in a header file, it may be any integer type, including unsigned char which would use 1 byte or int which may use 4 bytes on your system and other sizes for other architectures.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.