Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of initialization might be wrong #1

Open
kiskit opened this issue Dec 22, 2022 · 1 comment
Open

Order of initialization might be wrong #1

kiskit opened this issue Dec 22, 2022 · 1 comment

Comments

@kiskit
Copy link

kiskit commented Dec 22, 2022

Hello,

First and foremost, I'm not 100% certain of what I'm going to say, but...
In AppComponent.hpp, you initialize the m_cmdArgs member in the contructor (line 28).
A bit later in the code (line 70), you use the OATPP_CREATE_COMPONENT macro to create a component, and in the associated lambda, you try to use that m_cmdArgs member.
I've been struggling with my own code and I suspect it's because the OATPP_CREATE_COMPONENT macro (and most of all the lambda) will be executed before the AppComponent constructor.
So I think that, in you code, you try to make use of a member that has not been initialized.
On a more generic note, I've been trying to pass a configuration structure to that constructor. If I'm right, all component members that depend on it must be initialized differently, like in the body of the constructor. Maybe it's worth mentioning somewhere.

@kiskit
Copy link
Author

kiskit commented Dec 22, 2022

And now I've found out that you had thought of it, hence the previous declaration of m_cmdArgs to ensure the order of construction.
My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant