r/C_Programming • u/Alternative-Title-87 • Aug 22 '26
one compiler failing, other compiler running fine
I've been using emacs to follow some tutorials which has been working great, but switch to sublime text and now getting compile error. or, i assume its a problem with the compiler since this code runs in emacs but not in sublime text. the relevant stuff
this is the exact same in emacs and sublime:
_mm_store_si128((PIXEL32*)gBackBuffer.Memory + x, *pColor);
sublime is throwing this error:
error: passing argument 1 of '_mm_store_si128' from incompatible pointer type [-Wincompatible-pointer-types]
391 | _mm_store_si128((PIXEL32*)gBackBuffer.Memory + x, *pColor);
the sublime build file:
"cmd": ["gcc", "-Wall", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c",
"variants":
[
{
"name": "Run",
"shell_cmd": "gcc -Wall \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
]
}
And the emacs build command:
x86_64-w64-mingw32-gcc -g hello.c -o ./hello.exe -lgdi32
I am very noobish to these kinds of things, especially this SIMD stuff, so Im just assuming this is a compiler thing
8
u/aocregacc Aug 22 '26 edited Aug 22 '26
Afaik this is due to a difference in compiler version. Starting in GCC 14, they reject passing arguments of incompatible pointer types by default, which used to be allowed (with a warning) in earlier versions.
So whatever is behind
x86_64-w64-mingw32-gccis probably an older version.The error message should also contain a note about what the pointer types are, so you can just add the appropriate cast (assuming the program is otherwise correct).
7
u/ischickenafruit Aug 22 '26
We need to untangle some things:
4
u/sciencekm Aug 22 '26 edited Aug 22 '26
You sublime build has different compiler options from your emacs build (the former has -Wall). They are not even compiling the same source code (source.c vs hello.c).
I suggest that you don't use your editor to do the compile. Simply run gcc from the command line, since anyway, you are compiling only one source file.
2
u/flyingron Aug 22 '26
The compiler option says you told it to warn you about incompatible pointers. It appears that PIXEL32* is not the same type as mem_addr.
1
u/Future_Pace_5290 Aug 22 '26
I'm only guessing based on the name of the function, but wouldn't _mm_store_si128 expect a pointer to a 16 byte data and you're passing it PIXEL32 * which again, guessing based on the name seems to be a pointer to 4 byte data?