Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Realizing f strong typing

I have a problem by realizing a strong typed library function. The library function shall get a pointer to one byte and the number of bytes up on the pointer to be read.

But I does have the requirement that only local variables on the stack or global variables at the data area of the C Application may be processed by my function.

Here is a bad example:

void function(const void* const Data_pv, const uint8_t Size_u8)

void* Address = 0xFFAF;

function(Address, 8);

It shall not be possible to pass a pointer on void.

Here is a good example

uint32_t Data_u32 = 5;

function( (uint8_t*)&Data_32, sizeof(Data_u32));

Is there a rule of MISRA C supporting me by realizing my described problem ?

Thanks B3NNY
There isn't realy a single MISRA rule for this. This is inthe catagory of all comments will be meaningful. You need to catch this with human reviewing

See rule 21.1 which says something about run time checking.
You need a static checker with strong typing and dynamic or unit testing.

Forum Jump:

Users browsing this thread: 1 Guest(s)