Handmade Hero » Forums » Code » MSDN Windows Api syntax changes
peterpop
Peter Pop
1 posts
#21021 MSDN Windows Api syntax changes
2 weeks, 2 days ago Edited by Peter Pop on May 10, 2019, 7:50 a.m. Reason: Initial post

Hi

Does anyone know what happened to the MSDN documentation?

This really doesn't explain anything about the issue I have.

If I search for WinMain, today MSDN (or rather Windows Dev Center) shows:
1
2
3
4
5
6
int __clrcall WinMain(
  HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR     lpCmdLine,
  int       nShowCmd
);


In the past it was:
1
2
3
4
5
6
int CALLBACK WinMain(
  _In_  HINSTANCE hInstance,
  _In_  HINSTANCE hPrevInstance,
  _In_  LPSTR lpCmdLine,
  _In_  int nCmdShow
);


This is prevalent in the whole documentation.

Compiling with __clrcall gave me an error (I can't remember which, and it doesn't matter) so I changed it to CALLBACK. But I shouldn't have to remember this. The documentation should just be correct.

It was also nice that you could see the direction of the parameters.

What am I missing?
mrmixer
Simon Anciaux
600 posts
#21027 MSDN Windows Api syntax changes
2 weeks, 2 days ago Edited by Simon Anciaux on May 10, 2019, 4:14 p.m. Reason: typo

On WinMain I believe it's WINAPI or APIENTRY, not CALLBACK, but they all are defined as __stdcall. CALLBACK is on WinProc. WinProc documentation still uses the older style which I like better.

The doc for __crlcall as some information in paragraph 3:
Entry points are separate, compiler-generated functions. If a function has both native and managed entry points, one of them will be the actual function with the function implementation. The other function will be a separate function (a thunk) that calls into the actual function and lets the common language runtime perform PInvoke. When marking a function as __clrcall, you indicate the function implementation must be MSIL and that the native entry point function will not be generated.


I never used clr and __clrcall so I can't help you more. But you can drop the calling convention if you compile for 64 bits. Putting __clrcall on WinMain seems to be to encourage people to use managed code instead of native (maybe, I don't know).

That said in my opinion Microsoft documentation is getting worse. I've seen several times a TODO or TBD note in the descriptions and the presentation of arguments and their descriptions seem less visually clear to me.
mmozeiko
Mārtiņš Možeiko
1924 posts / 1 project
#21029 MSDN Windows Api syntax changes
2 weeks, 2 days ago

__clrcall is for C++/CLI. It is completely irrelevant for native C and C++ code. They messed up something in documentation.

For last two or so years they are slowly migrating documentation from somewhere to elsewhere. And during this migration I have seen a lot of things are breaking. Either defines are wrong, or missing function argument names, or missing argument descriptions.. Complete shit-show.

I suggest download MSDN documentation for using it offline. Good option to do this is to use Zeal with MSDN docs from here.