You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The functions I've seen in this library do not label unmodified parameters with const qualifiers. This causes some problems with a lot of existing code in a project that I'm working on.
With enough Clang warnings flags, Clang starts to complain:
warning: passing 'const vec3' (aka 'const float[3]') to parameter of type 'float *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
In order to fix this, I must do an ugly const-cast in order to remove the error:
glm_vec3_add((float*) a, (float*) b, sum);
Therefore, I suggest adding const qualifiers to the unmodified parameters of each function signature. In this case, this would change the signature of glm_vec3_add from void glm_vec3_add(vec3 a, vec3 b, vec3 dest) to void glm_vec3_add(const vec3 a, const vec3 b, vec3 dest).
This would not be too hard to add, or break any existing code, it would just take a little while to update each function signature. For the sake of const-correctness, please consider making this change!
The text was updated successfully, but these errors were encountered:
The functions I've seen in this library do not label unmodified parameters with const qualifiers. This causes some problems with a lot of existing code in a project that I'm working on.
Say that I'm doing this:
With enough Clang warnings flags, Clang starts to complain:
warning: passing 'const vec3' (aka 'const float[3]') to parameter of type 'float *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
In order to fix this, I must do an ugly const-cast in order to remove the error:
Therefore, I suggest adding const qualifiers to the unmodified parameters of each function signature. In this case, this would change the signature of
glm_vec3_add
fromvoid glm_vec3_add(vec3 a, vec3 b, vec3 dest)
tovoid glm_vec3_add(const vec3 a, const vec3 b, vec3 dest)
.This would not be too hard to add, or break any existing code, it would just take a little while to update each function signature. For the sake of const-correctness, please consider making this change!
The text was updated successfully, but these errors were encountered: