language lawyer - Does MISRA C 2012 say not to use bool -


i in stages of framing stuff out on new project.

i defined function return type of "bool"

i got output pc-lint

    including file sockets.h (hdr) bool sock_close(uint8_t socket_id); ^ "lint: sockets.h (52, 1) note 970: use of modifier or type '_bool' outside of typedef [misra 2012 directive 4.6, advisory]" 

i went ahead , defined in header shut lint up:

typedef bool bool_t; 

then started wondering why had , why changed anything. turned misra 2012 dir 4.6. concerned width of primitive types short, int, , long, width, , how signed.

the standard not give amplification, rational, exception, or example bool.

bool explicitly defined _bool in stdbool.h in c99. criteria apply bool?

i thought _bool explicitly "smallest standard unsigned integer type large enough store values 0 , 1" according section 6.2.5 of c99. know bool unsigned. matter of fact _bool not fixed width , subject being promoted somehow that's issue? because rational seem contradict notion.

adherence guideline not guarantee portability because size of int type may determine whether or not expression subject integer promotion.

how putting typedef bool bool_t; change - because nothing indicate width or signdedness in doing so? width of bool_t platform dependent too. there better way redefine bool?

a type must not defined specific length unless implemented type of length

so typedef bool bool8_t; should totally illegal.

is gimpel wrong in interpretation of directive 4.6 or spot on?

use of modifier or type '_bool' outside of typedef [misra 2012 directive 4.6, advisory]

that's nonsense, directive 4.6 concerned using types in stdint.h rather int, short etc. directive the basic numerical types. bool has nothing directive whatsoever, not numerical type.

for reasons unknown, misra-c:2012 examples use weird type called bool_t, isn't standard. misra no means enforce type used anywhere, particularly not enforce in directive 4.6, doesn't mention booleans. misra not discourage use of bool or _bool anywhere.

is gimpel wrong in interpretation of directive 4.6

yes, tool giving incorrect diagnostics.

in addition, may have configure tool (if possible) tell bool type used. 5.3.2 mentions might have if not using _bool, implying static analysers must understand _bool. if bool type correctly configured, dir 4.6 has nothing it.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -