* Default User, on 14.03.2011 01:23:
> Normally, in C++ one doesn't use void in a function declaration when it
> takes no parameters. You need to in C. So what about a C++ function declared
> with an extern "C"? Example:
>
> extern "C" void __declspec(dllexport) functionName() // does this need to be
> (void)?
>
>
> As is probably evident, this is in a Windows DLL. Right now, the entire
> program is C++. I don't know if it will ever be used with C modules.
In C the 'void' formal argument list tells the C compiler that this function
does not accept any arguments.
But the C linkage link level name doesn't tell this: by convention it doesn't
depend on the function signature.
And so if the above had truly produced a C convention link level name, then a
"void" would not serve any purpose, since it's not seen by the C compiler, and
since with true C link level names it would not affect the link level name.
However, the above is Microsoft stuff.
With Microsoft's conventions "extern C" does not necessarily produce C
convention link level names. And so the answer is platform- and compiler-
specific. I do not know that answer, but you can use a tool such as Microsoft's
"dumpbin" to check the link-level names, or, ask in a Microsoft group (it's
off-topic here since this group deals only with standard C++).
Cheers & hth.,
- Alf
--
blog at <url: http://alfps.wordpress.com>
|