Pelles C forum

Pelles C => General discussions => Topic started by: dezmand07 on February 17, 2023, 08:08:40 AM

Title: The auto keyword
Post by: dezmand07 on February 17, 2023, 08:08:40 AM
Hello.
I switched from Visual Studio to Pelles C.
Why is the auto keyword implemented in Pelles C if it doesn't work?
Code: [Select]
auto hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
Quote
warning #2099: Missing type specifier; assuming 'int'.
error #2082: Invalid initialization type; expected 'int' but found 'void *'.
error #2168: Operands of '=' have incompatible types 'int' and 'void *'.
Title: Re: The auto keyword
Post by: TimoVJL on February 17, 2023, 11:20:00 AM
Code: [Select]
HANDLE CreateToolhelp32Snapshot(  [in] DWORD dwFlags,  [in] DWORD th32ProcessID);CreateToolhelp32Snapshot returns a HANDLE, not int.
Title: Re: The auto keyword
Post by: John Z on February 17, 2023, 11:20:52 AM
Hi dezmand07,

I think perhaps a misunderstanding of the use. 
The 'auto' keyword does not determine the type it determines the scope, location, initial value and where stored.

So the use of auto in the case below is missing the return value type HANDLE.

Attached is a helpful table on storage classes sourced from from https://www.geeksforgeeks.org/storage-classes-in-c/

John Z
Title: Re: The auto keyword
Post by: dezmand07 on February 17, 2023, 12:42:55 PM
Code: [Select]
HANDLE CreateToolhelp32Snapshot(  [in] DWORD dwFlags,  [in] DWORD th32ProcessID);CreateToolhelp32Snapshot returns a HANDLE, not int.
Yes I know that. That is why I did not in vain mention about Visual Studio.
I thought that in Pelles C it's implemented.
Title: Re: The auto keyword
Post by: dezmand07 on February 17, 2023, 12:45:02 PM
Attached is a helpful table on storage classes sourced from from https://www.geeksforgeeks.org/storage-classes-in-c/
Thank you. This clears things up a bit.
Title: Re: The auto keyword
Post by: frankie on February 17, 2023, 09:24:39 PM
MS C is MS C, not a C standard compliant at all.