Oberon Community Platform Forum
July 20, 2017, 09:23:44 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: {WINAPI} calling convention with return parameter  (Read 1684 times)
fnecati
Jr. Member
**
Posts: 60


« on: October 14, 2011, 04:38:06 PM »

Hi,

If a function defined with {WINAPI} calling convention which has a return parameter, and, using this function by dropping the return value is possible in WinAos.

For example, the below function is defined in User32.Mod,
Code:
MessageBeep-: PROCEDURE {WINAPI} (uType: LONGINT): BOOL;


Now, it is possible use this function as:
Code:
User32.MessageBeep(2000); (* <--- this works!, by omitting the retun value *)

and as;
Code:
VAR
 res: User32.BOOL;
  ...
 res := User32.User32.MessageBeep(2000);
 ..


Is this behaviour is a feature of {WINAPI} cc?

If a function is defined with {C} calling convention, the compiler gives error : calling procedure with non-void return type.


Logged
negelef
Administrator
Jr. Member
*****
Posts: 55


« Reply #1 on: October 17, 2011, 10:54:26 AM »

This behaviour is not really a feature but was added while WinAos was developed. Once WinAos was running, people forgot to remove the relaxaion such that it is still possible to drop the return value and some WinAos specific code still relies on that. However, the adaption to calling conventions of other compilers only specifies how to implement actual function calls. There was never the intention to mimic the semantics and behaviour of other programming languages.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!