H
holysmoke
Hi all,
I have a function
void actualfunction(unsigned int t, unsigned int lineno)
{
....
}
I want that it is called only from a macro I wrote for it (I don't
want to use a wrapper function) like,
#define FUNCTION(a) actualfunction((a), __LINE__)
How to do I insure that actualfunction is only called as FUNCTION?
One thing I could do is, call another function that sets a global
variable and then test that variable in 'actualfunction'.
#define FUNCTION(a) setTest(); \
actualfunction((a), __LINE__); \
void setTest(void)
{
static unsigned char test;
test = 0xFF;
}
void actualfunction(unsigned int t, unsigned int lineno)
{
assert(test == 0xFF);
test = 0x00;
....
}
BTW I'm ok to ignore the case where some calls setTest and then
actualfunction directly but this is a run time check, is a compile
time check posssible?
Would appreciate any pointers. Thanks!
I have a function
void actualfunction(unsigned int t, unsigned int lineno)
{
....
}
I want that it is called only from a macro I wrote for it (I don't
want to use a wrapper function) like,
#define FUNCTION(a) actualfunction((a), __LINE__)
How to do I insure that actualfunction is only called as FUNCTION?
One thing I could do is, call another function that sets a global
variable and then test that variable in 'actualfunction'.
#define FUNCTION(a) setTest(); \
actualfunction((a), __LINE__); \
void setTest(void)
{
static unsigned char test;
test = 0xFF;
}
void actualfunction(unsigned int t, unsigned int lineno)
{
assert(test == 0xFF);
test = 0x00;
....
}
BTW I'm ok to ignore the case where some calls setTest and then
actualfunction directly but this is a run time check, is a compile
time check posssible?
Would appreciate any pointers. Thanks!