10-01-2009, 02:48 PM
Hello,
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:
It shall not be possible to pass a pointer on void.
Here is a good example
Is there a rule of MISRA C supporting me by realizing my described problem ?
Thanks B3NNY
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:
Code:
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
Code:
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
<t></t>