This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: (const void) as return type
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: Christoph Csebits <christoph dot csebits at frequentis dot com>
- Cc: ecos discuss list <ecos-discuss at sources dot redhat dot com>
- Date: Wed, 9 Jul 2003 17:52:07 +0200
- Subject: Re: [ECOS] (const void) as return type
- References: <20030709173447.A4264@frequentis.com>
On Wed, Jul 09, 2003 at 05:34:47PM +0200, Christoph Csebits wrote:
> hi,
>
> in infra/current/include/cyg_ass.h line 193
>
> the cyg_check_func_ptr function expects
> a pointer to a function with "const void"
> as return type.
>
> Does it make sense to have a function
> returning a _const_ void ?
externC cyg_bool cyg_check_func_ptr(const void (*ptr)(void));
# define CYG_CHECK_FUNC_PTRC( _ptr_ ) \
CYG_MACRO_START \
if ( !cyg_check_func_ptr((const void (*)(void))(_ptr_))) \
CYG_ASSERT_DOCALL("function pointer (" #_ptr_ ") is valid"); \
CYG_MACRO_END
#else // CYGDBG_USE_ASSERTS
It does not really matter. It does not call the function, it just
needs to know the address of it to make sure its in the code
section. All this casting is just to turn some random function into a
specific type which can then be passed into cyg_check_func_ptr without
compiler warnings. But this obviously fails on 3.2.2 :-(
I've always found function pointers confusing, but doesn't that * mean
its a const void *. ie its a const pointer to a non const void.
> BTW:
> powerpc-eabi-gcc (GCC) 3.2.2 with -W option
> produces the warning: type qualifiers ignored on function return type
What exactly is causing the problem? What is the value of _ptr_.
Maybe if _ptr_ is a const void (const *) you might get this warning
since you are discards a const.
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss