-
Notifications
You must be signed in to change notification settings - Fork 56
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
fix build for gcc 15 #3389
base: nat/poc_cpp23
Are you sure you want to change the base?
fix build for gcc 15 #3389
Conversation
@@ -310,7 +310,7 @@ const LLVoiceVersionInfo LLVoiceClient::getVersion() | |||
} | |||
else | |||
{ | |||
LLVoiceVersionInfo result; | |||
LLVoiceVersionInfo result = {}; | |||
result.serverVersion = std::string(); | |||
result.voiceServerType = std::string(); | |||
result.mBuildVersion = std::string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If serverVersion
, voiceServerType
and mBuildVersion
are std::string
members of LLVoiceVersionInfo
, wouldn't the new initialization at line 313 make lines 314-316 redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check.
There's a good chance that lines 314 to 316 can be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that lines 314 to 316 could be deleted.
When defining a variable, we can also use imperative initialization, but which is better?
e.g.
LLVoiceVersionInfo result{
.voiceServerType = std::string()
, .internalVoiceServerType = std::string()
, .majorVersion = 0
, .minorVersion = 0
, .serverVersion = std::string()
, .mBuildVersion = std::string()
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Designated initialization would be great if any one of those members had a non-default value. But to be honest, at least from my perspective,
LLVoiceVersionInfo result{};
is clearer than the designated initialization you wrote above. I think we all understand that value-initializing std::string
produces an empty string, and value-initializing an int
produces 0. If, in reading the code, I hit that 8-line initialization expression, I must consider it to understand why it's written it out that way. Is any one of those members being initialized to a non-default value? No? Are we intentionally omitting mention of any members, maybe because they're declared with their own initial values in the struct definition? That sends me looking for the struct definition.
If I see a one-line initialization to {}
, I can nod and understand that all members are initialized to their default values, and go on.
all fixed |
Fix build error for gcc 15