Closed Bug 1330235 Opened 3 years ago Closed 2 years ago

Remove NS_STDCALL_FUNCPROTO

Categories

(Core :: XPCOM, defect, trivial)

All
Linux
defect
Not set
trivial

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: gcp, Assigned: xidorn)

Details

Attachments

(1 file)

While trying to figure out https://bugzilla.mozilla.org/show_bug.cgi?id=1329593#c8
I noticed:

https://hg.mozilla.org/mozilla-central/annotate/e68cbc3b5b3d3fba4fe3e17e234713020f44e4a0/xpcom/base/nscore.h#l139

The GCC versions where this bug got fixed are already so old that we don't compile with them any more. So this workaround can go away.
We should actually be able to use decltype everywhere we are currently using this macro. This is functionally same as the nonstandard typeof, and available in all compilers we currently use.
working on a patch.
Assignee: nobody → xidorn+moz
Comment on attachment 8865846 [details]
Bug 1330235 - Remove NS_STDCALL_FUNCPROTO and replace its usage with decltype.

https://reviewboard.mozilla.org/r/137450/#review140582

This is a nice cleanup.  r=me assuming that the `__stdcall` annotation is properly kept around by `decltype` on Windows.
Attachment #8865846 - Flags: review?(nfroyd) → review+
I'm assuming that it is kept around correctly if it builds.
I would assume that it builds no matter what; the real test is if you try to call a function, e.g.

  typedef decltype(&SomeStdCallMethod) Method;
  ...
  ...Method aMethod...
  p->*aMethod(...);

and the correct things happen.
No, it doesn't build.

The following code doesn't build with MSVC on x86:
class Test {
	void __stdcall funca(int a, int b) { printf("a: %d,%d\n", a, b); }
	void funcb(int a, int b) { printf("b: %d,%d\n", a, b); }
public:
	typedef decltype(&Test::funca) Func;
	static Func kFuncs[];
};
Test::Func Test::kFuncs[] = {
	&Test::funca,
	&Test::funcb,
};

The compiler would complain:
> Error C2440 'initializing': cannot convert from 'void (__thiscall Test::* )(int,int)' to 'Test::Func'

but it builds and works properly on x64.
Pushed by xquan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7c9e467c10b6
Remove NS_STDCALL_FUNCPROTO and replace its usage with decltype. r=froydnj
https://hg.mozilla.org/mozilla-central/rev/7c9e467c10b6
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.