Update run-time-library-behavior.md - inaccurate initialisation of AFX_EXTENSION_MODULE structure#2612
Merged
Merged
Conversation
The first two parameters of the structure AFX_EXTENSION_MODULE are BOOL and HMODULE. So initialization with = { NULL, NULL } is misleading: first NULL is FALSE (or 0 due to BOOL is defined as int). In fact this expression cannot be transformed to modern C++ equivalent = { nullptr, nullptr }.
struct AFX_EXTENSION_MODULE
{
BOOL bInitialized;
HMODULE hModule;
HMODULE hResource;
CRuntimeClass* pFirstSharedClass;
COleObjectFactory* pFirstSharedFactory;
};
Contributor
|
@yury-fedorov : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
Contributor
|
@yury-fedorov |
Contributor
Author
|
You are absolutely right. It is section 3.5.7 of the C89 specification. We
can keep it with default initialization.
…On Sat, Nov 21, 2020 at 12:44 PM Colin Robertson ***@***.***> wrote:
@yury-fedorov <https://github.com/yury-fedorov>
I'm confused why any initialization is required at all. Aren't global
statics zero-initialized by default? The struct AFX_EXTENSION_MODULE type
is POD and has no constructor.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2612 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFKHLNO6T6HQUGOOSBVFVULSQ6RYVANCNFSM4T5NCBNQ>
.
|
Adjusting the code after the feedback.
Contributor
|
@yury-fedorov : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
Contributor
Author
|
@corob-msft Could you please take a look on the new simplified version based on your feedback? |
colin-home
approved these changes
Nov 23, 2020
Contributor
colin-home
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first two parameters of the structure AFX_EXTENSION_MODULE are BOOL and HMODULE. So initialisation with = { NULL, NULL } is inaccurate: first NULL is FALSE (or 0 due to BOOL is defined as int). In fact this expression cannot be transformed to modern C++ equivalent = { nullptr, nullptr }.
struct AFX_EXTENSION_MODULE
{
BOOL bInitialized;
HMODULE hModule;
HMODULE hResource;
CRuntimeClass* pFirstSharedClass;
COleObjectFactory* pFirstSharedFactory;
};