3 ms·
At this point, C and C++ are not compatible. Please stop with this "Oh, just compile C with a C++ compiler." That ship has sailed over twenty years ago with C
by spc476 2y ago
At this point, C and C++ are not compatible. Please stop with this "Oh, just compile C with a C++ compiler." That ship has sailed over twenty years ago with C99. One major difference is designated initializers, which works differently between C and C++ [1]. And C also allows structure literals in function calls:
cgci = XCreateGC(
display,
window,
GCForeground | GCBackground | GCFont,
&(XGCValues) {
.foreground = ccwhite,
.background = ccblack,
.font = cfont->fid,
}
);
[1] C++ requires the fields to be initialized in order; C doesn't have this restriction.
- wahern 2y agoCompound literals are especially pernicious[1] because GCC and (I think) clang support them in C++ mode, but they have expression lifetime like C++ temporary objects, not block lifetime as in C. That's a guaranteed recipe for dangling pointers and stack smashing/snooping. [1] From a C++ is just a C superset perspective. In C compound literals are awesome.