I am using the following flags (where cc is either gcc 4.2 or clang 8.0):
$ cc -Wall -Werror -pedantic -ansi -std=c89 main.c
(I know the -ansi flag is a bit redundant in this case)
The following gives me the expected error
main.c:31:8: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
vec3 abc = {0};
int main()
{
vec3 a = {0};
vec3 b = {0};
Vec3(2, 2, 2);
vec3 abc = {0}; // Declared after a function call
return 0;
}
However, the following does not
int main()
{
vec3 a = Vec3(0, 1, 2);
vec3 b = Vec3(0, 1, 2);
vec3 abc = {0}; // Declared after a function call
return 0;
}
Surely initializing a variable with a function still counts as mixing declarations and code?
The Vec3 function is very basic; no inline flag set, etc.
vec3 Vec3(float x, float y, float z)
{
vec3 rtn = {0};
rtn.x = x;
rtn.y = y;
rtn.z = z;
return rtn;
}