On 08/11/17 10:21, Sergey A. Borshch wrote:
> On 08.11.2017 11:03, David Brown wrote:
>> (Also, if you are writing C rather
>> than C++, your function declaration is not correct.)  The sensible way
>> to write this is:
>> static inline uint16_t GetStackPointer(void)
>> {
>>     return (SPH << 8) | SPL;
>> }
> It's not correct declaration too. Function name clearly states that it
> is returning pointer, so it should return... pointer:
> static inline void * GetStackPointer(void)
> {
>      return (void *)((SPH << 8) | SPL);
> }

I viewed it more as meaning "get the contents of the stack pointer
register", rather than "get the pointer to the current top-of-stack".
That is up to the OP, to choose what he wants here.

My point was merely that in C (but not C++), a function taking no
parameters should be declared with a "void" parameter list.  Omitting
that is allowed (and the code generated is identical), but it is an
obsolete feature in C.  If the OP was writing C++, then it is fine.

AVR-GCC-list mailing list

Reply via email to