avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] push r1, pop r0


From: David Brown
Subject: Re: [avr-gcc-list] push r1, pop r0
Date: Wed, 8 Nov 2017 11:17:08 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]